ASP.Net/ADO.net Database/DataGrid Style
Версия от 15:30, 26 мая 2010; (обсуждение)
<%@ 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>