日期:2013-09-15  浏览次数:20546 次

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>
                          &n