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

 

<!DOCTYPE html>

 

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

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

    <title>GridView Example 6</title>

</head>

<body bgcolor="#ffcc99">

   

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

 

 

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

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

            <Columns>

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

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

                <asp:BoundField DataField="QOH" HeaderText="Quantity Available" />

When binding a GridView to an ArrayList, the DataField property value must be the Property name of the objects stored in the ArrayList that you want to bind.

 

 
                <asp:BoundField DataField="Price" DataFormatString="{0:c}" HeaderText="Price" />

            </Columns>

        </asp:GridView>

    </form>

 

</body>

</html>