使用ADO+(二), 设定 DataGrid 的外观

<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<!-- <%@ Page Trace="True" %> -->
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>


<Html>
<Body BgColor="White">
<H3>使用 ADO+, 结合 DataGrid -- ADO+.aspx <HR></H3>

<asp:DataGrid HeaderStyle-BackColor="Cyan" id="Grid1" runat="server"/>

</Body>
</Html>

<script Language="VB" runat="server">

   Sub Page_Load(Src As Object, e As EventArgs)
      Grid1.DataSource = CreateDataView( "pubs", "Authors" )
      Grid1.DataBind()
   End Sub


Function CreateDataView( Db As String, Table As String ) As DataView
   Dim ConnStr, SQL As String

   ConnStr = "server=hnby-dom;uid=sa;pwd=;database="&Db

   
   Dim Conn As SqlConnection
   Dim Cmd As SqlDataAdapter
   Conn = new SqlConnection(ConnStr)
   Cmd = New SqlDataAdapter( "Select * from " & Table, ConnStr )
   Dim ds As DataSet = new DataSet()
   Cmd.Fill(ds, Table)
   CreateDataView = new DataView(ds.Tables(Table))
End Function

</script>


和使用ADO+(一)不同,这里用到一个函数CreateDataView,你可以单独吧这个函数做到一个包含页面里。
------------------------------------------------
以上在win2000server,win2000professional,sql6.0,Microsoft .NET Framework SDK beta2测试通过。
实例:http://202.102.247.235/aspx/ADO2.aspx

11AI60cc0I0O.jpg
seover="window.status='正文--使用ADO+(二), 设定 DataGrid外观';return true">
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
阅读更多
个人分类: .net
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭