<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<html>
<head>
<title>Disabling AutoGenerateColumns in a GridView</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 WHERE type='stove'";
myGrid.DataSource = fetchData ( query, "gear" );
myGrid.DataBind ( );
}
}
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc" -->
<div class="header"><h2>Disabling AutoGenerateColumns in a GridView</h2></div>
<hr size=1 width=92%>
<form runat="server">
<div align="center">
<asp:gridview id="myGrid" runat="server"
cellpadding=5 font-size="9pt"
headerstyle-backcolor="lightsteelblue"
headerstyle-font-bold
autogeneratecolumns=false>
<columns>
<asp:boundfield headertext="Brand"
datafield="Brand" />
<asp:boundfield headertext="Model"
datafield="Model" />
<asp:boundfield headertext="Description"
datafield="Description" />
<asp:boundfield headertext="Price"
datafield="Price"
htmlencode=false
dataformatstring="{0:c}"
itemstyle-horizontalalign="right" />
<asp:templatefield>
<itemtemplate>
<asp:hyperlink runat="server"
navigateurl='<%# Eval ( "ProductID", "details_gear.aspx?id={0}" ) %>'>
<img width=75 border=0 runat="server"
src='<%# Eval ( "ProductID", "~/shared/images/gear/{0}.jpg" ) %>'
alt='<%# Eval ( "Model" ) %>' />
</asp:hyperlink>
</itemtemplate>
</asp:templatefield>
</columns>
</asp:gridview>
</div>
</form>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>