<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GridViewExample2.aspx.cs" Inherits="GridViews.GridViewExample2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<body bgcolor="#99ccff">
<h3>This GridView example has its
columns manually constructed using DataBound Fields
& Template Fields</h3>
<h4>This GridView is dynamically
bound to data retrieved from the database, and <br />
the columns
are no longer automatically generated (property: AutoGenerateColumns=False).</h4>
<form id="form1" runat="server">
<asp:Button ID="btnOrder" runat="server" Text="Order Products" Height="31px" Width="141px" OnClick="btnOrder_Click" />
<br /> <br />
<asp:Label ID="lblDisplay" runat="server" ForeColor="#CC0000"></asp:Label>
<br /> <br />
TemplateField used
to put a checkbox in the first column for each row.
<asp:GridView ID="gvProducts" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="Select Product">
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ProductNumber" HeaderText="Product ID" />
<asp:BoundField DataField="Description" HeaderText="Description" />
<asp:BoundField DataField="QOH" HeaderText="Quantity Available" />
<asp:BoundField DataField="Price" DataFormatString="{0:c}" HeaderText="Price" />
The DataField property value must be the same value as what
appears in the database (or alias used in SELECT statement). The value must
be the database field name that you want to bind to this column for each
row to display.
</Columns>
</asp:GridView>
</form>
</body>
</html>