<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<html>
<head>
<title>GridView BoundField 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 = fetchReader ( query, "dbtutor" );
myGrid.DataBind ( );
}
}
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc" -->
<div class="header"><h2>GridView <span class="hilite">BoundField</span> Example</h2></div>
<hr size=1 width=92%>
<form runat="server">
<div align="center">
<asp:gridview id="myGrid" runat="server"
width=90% cellpadding=5
font-size="9pt"
autogeneratecolumns=false
enableviewstate=false>
<headerstyle backcolor="steelblue"
forecolor="beige" />
<rowstyle verticalalign="top" />
<columns>
<asp:boundfield headertext="Type"
datafield="ProductType" />
<asp:boundfield headertext="Brand/Model"
datafield="ProductName" />
<asp:boundfield headertext="Description"
datafield="ProductDescription" />
<asp:boundfield headertext="Price"
datafield="UnitPrice"
htmlencode=false
dataformatstring="{0:n2}"
itemstyle-horizontalalign="right" />
</columns>
</asp:gridview>
</div>
</form>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>