<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<html>
<head>
<title>DataGrid BoundColumn Example</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<script language="C#" runat="server" src="fetchData_oledb.cs" />
<script language="C#" runat="server">
void Page_Load ( Object src, EventArgs e ) {
if ( !IsPostBack ) {
string query = "SELECT * FROM products";
myGrid.DataSource = fetchData ( query, "dbtutor" );
myGrid.DataBind ( );
}
}
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc" -->
<div class="header"><h2>DataGrid BoundColumn Example</h2></div>
<hr size=1 width=92%>
<p align="center">
<asp:datagrid id="myGrid" runat="server"
width="92%"
cellpadding=5
font-size="9pt"
autogeneratecolumns=false
headerstyle-backcolor="lightsteelblue"
headerstyle-font-bold
itemstyle-verticalalign="top">
<columns>
<asp:boundcolumn headertext="Type"
datafield="ProductType" />
<asp:boundcolumn headertext="Brand/Model"
datafield="ProductName" />
<asp:boundcolumn headertext="Description"
datafield="ProductDescription" />
<asp:boundcolumn headertext="Price"
datafield="UnitPrice"
dataformatstring="{0:c}"
itemstyle-horizontalalign="right" />
</columns>
</asp:datagrid>
</p>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>