<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GridViewExample7.aspx.cs" Inherits="GridViews.GridViewExample7" %>

 

<!DOCTYPE html>

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

    <title>GridView Example 7</title>

</head>

<body bgcolor="#ffcc99">

   

    <h3>This GridView example demonstrates binding an ArrayList to a GridView.</h3>

    <ul>

        <li>Column 1: BoundField column that is bound to the <b>ProductId</b> property of a Product object stored in the ArrayList.</li>

        <li>Column 2: BoundField column that is bound to the <b>Description</b> property of a Product object stored in the ArrayList.</li>

        <li>Column 3: BoundField column that is bound to the database field <b>Price</b> property of a Product object stored in the ArrayList.</li>

        <li>Column 4: TemplateField column that has a textbox bound to the <b>QOH</b> property of a Product object stored in the ArrayList.</li>

        <li>Column 5: TemplateField column that has a textbox used with the Update button to modify the QOH value for an object stored the ArrayList.</li>

        <li>Column 6: CommandField column with Select button. Codebehind displays the ProductId of the selected row.</li>

        <li>Column 7: CommandField column Edit button. Enables update of QOH property of a Product object in Column 5.</li>

    </ul>

 

    <form id="form1" runat="server">

  

        <asp:Label ID="lblDisplay" runat="server" ForeColor="#CC0000"></asp:Label>

        <br /> <br />

 

        <asp:GridView ID="gvProducts" runat="server" AutoGenerateColumns="False" OnRowCancelingEdit="gvProducts_RowCancelingEdit"

  OnRowEditing="gvProducts_RowEditing" OnRowUpdating="gvProducts_RowUpdating" OnSelectedIndexChanged="gvProducts_SelectedIndexChanged">

            <Columns>

                <asp:BoundField DataField="ProductId" HeaderText="Product ID" ReadOnly="true" />

                <asp:BoundField DataField="Description" HeaderText="Description" ReadOnly="true" />

                <asp:BoundField DataField="Price" DataFormatString="{0:$###,##0.00}" HeaderText="Price" />

                <asp:TemplateField HeaderText="QOH">

                    <ItemTemplate>

                        <asp:TextBox ID="txtQOH" runat="server" Height="20px" Width="64px"

                            Text='<%# Bind("QOH") %>'></asp:TextBox>

                    </ItemTemplate>

                </asp:TemplateField>

                <asp:TemplateField HeaderText="Add Qty">

                    <ItemTemplate>

                        <asp:TextBox ID="txtQtyAdd" runat="server" Height="20px" Width="64px"></asp:TextBox>

                    </ItemTemplate>

                </asp:TemplateField>

                <asp:CommandField ButtonType="Button" HeaderText="Show Product"

                    ShowSelectButton="True"></asp:CommandField>

                <asp:CommandField ButtonType="Button" HeaderText="Edit Product"

                    ShowEditButton="True" />

            </Columns>

        </asp:GridView>

    </form>

 

</body>

</html>