datagrid|创建
Women
NameAgeGenderStaci 22 F Niki 21 F Candy 44 F Erica 32 F Andrea 23 F Susan 36 F
Men
NameAgeGenderAlex 24 M John 39 M Chad 23 M Greg 48 M
<%@ Page Language="VB" %><%@ Import Namespace="System.Data" %><%@ Import Namespace="System.Data.SqlClient" %> <script runat="server"> Sub Page_Load(Sender As Object, E As EventArgs) Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("DSN_aspa")) Dim myAdapter As New SqlDataAdapter("SELECT PersonName,PersonAge,PersonGender FROM tblPeople", myConnection) Dim myDataSet As New DataSet() Try myAdapter.Fill(myDataSet, "People") Dim myDataView As DataView = myDataSet.Tables("People").DefaultView myDataView.RowFilter = "PersonGender='F'" myFemaleDataGrid.DataSource = myDataView myFemaleDataGrid.DataBind() myDataView.RowFilter = "PersonGender='M'" myMaleDataGrid.DataSource = myDataView myMaleDataGrid.DataBind() Catch myException As Exception Response.Write("An error has occurred: " & myException.ToString()) End Try End Sub</script><html> <head> </head> <body> <form runat="server"> <p> Women<br> <asp:datagrid id="myFemaleDataGrid" runat="server" autogeneratecolumns="false" enableviewstate="false"> <columns> <asp:templatecolumn headertext="Name"> <itemtemplate> <span><%# Container.DataItem("PersonName") %></span> </itemtemplate> </asp:templatecolumn> <asp:templatecolumn headertext="Age"> <itemtemplate> <span><%# Container.DataItem("PersonAge") %></span> </itemtemplate> </asp:templatecolumn> <asp:templatecolumn headertext="Gender"> <itemtemplate> <span><%# Container.DataItem("PersonGender") %></span> </itemtemplate> </asp:templatecolumn> </columns> </asp:datagrid> </p> <p> Men<br> <asp:datagrid id="myMaleDataGrid" runat="server" autogeneratecolumns="false" enableviewstate="false"> <columns> <asp:templatecolumn headertext="Name"> <itemtemplate> <span><%# Container.DataItem("PersonName") %></span> </itemtemplate> </asp:templatecolumn> <asp:templatecolumn headertext="Age"> <itemtemplate> <span><%# Container.DataItem("PersonAge") %></span> </itemtemplate> </asp:templatecolumn> <asp:templatecolumn headertext="Gender"> <itemtemplate> <span><%# Container.DataItem("PersonGender") %></span> </itemtemplate> </asp:templatecolumn> </columns> </asp:datagrid> </p> </form> </body></html>
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索as
, 中创
rowfilter
datagrid filter row、wpf datagrid dataset、dataset 绑定datagrid、datagrid dataset、c datagrid dataset,以便于您获取更多的相关知识。
时间: 2024-10-30 04:16:23