ASP.Net/ADO.net Database/DataGrid Style

Материал из .Net Framework эксперт
Версия от 11:50, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Choose FooterStyle, HeaderStyle, PagerStyle, SelectedItemStyle, ItemStyle style for asp:datagrid

<%@ Page Language="VB" %>
<script runat="server">
  Function AllDiscs() As System.Data.SqlClient.SqlDataReader
    Dim connectionString As String = "server="(local)\NetSDK"; trusted_connection=true; Database="CAM""
    Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)
    
    Dim queryString As String = "SELECT * FROM Employee"
    Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
    
    sqlConnection.Open
    Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.rumandBehavior.CloseConnection)
    
    Return dataReader
  End Function
    
  Sub Page_Load(sender As Object, e As EventArgs)
    
    DataGrid1.DataBind()
    
  End Sub
</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <asp:DataGrid id="DataGrid1" runat="server" DataSource="<%# AllDiscs() %>" BorderStyle="None" BorderWidth="1px" BorderColor="#CC9966" BackColor="White" CellPadding="4">
            <FooterStyle forecolor="#330099" backcolor="#FFFFCC"></FooterStyle>
            <HeaderStyle font-bold="True" forecolor="#FFFFCC" backcolor="#990000"></HeaderStyle>
            <PagerStyle horizontalalign="Center" forecolor="#330099" backcolor="#FFFFCC"></PagerStyle>
            <SelectedItemStyle font-bold="True" forecolor="#663399" backcolor="#FFCC66"></SelectedItemStyle>
            <ItemStyle forecolor="#330099" backcolor="White"></ItemStyle>
        </asp:DataGrid>
    </form>
</body>
</html>