<%@ Page Language="C#" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">
void Page_Load(object sender, EventArgs e) {
string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+ Server.MapPath("EmployeeDatabase.mdb;");
string CommandText = "select * from employee";
OleDbConnection myConnection = new OleDbConnection(ConnectionString);
OleDbCommand myCommand = new OleDbCommand(CommandText, myConnection);
myConnection.Open();
DataGrid1.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
DataGrid1.DataBind();
myConnection.Close();
}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:datagrid id="DataGrid1"
runat="server"
CellSpacing="1"
GridLines="None"
CellPadding="3"
BackColor="White"
ForeColor="Black"
EnableViewState="False">
<HeaderStyle font-bold="True" forecolor="white" backcolor="#4A3C8C"></HeaderStyle>
<ItemStyle backcolor="#DEDFDE"></ItemStyle>
</asp:datagrid>
</form>
</body>
</html>
3.38.DataGrid Style |
| 3.38.1. | Set HeaderStyle and ItemStyle for asp:DataGrid |