How to bind grid in ASP.NET?
<p>I cant bind my Grid. I dont know what I am doing wrong, the grid appears empty when I run the program.</p>

<p>here is my code ::</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            this.BindGrid(this.GridView1);


    }
    private void BindGrid(GridView grid)
    {
        SqlCommand cmd = new SqlCommand("Select * from Person", cn);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        da.Fill(dt);
        grid.DataSource = dt;
        grid.DataBind();
    }


&lt;body&gt;
    &lt;form id="form1" runat="server"&gt;
    &lt;div style="margin-left: 240px"&gt;
    &lt;asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" 
            GridLines="None" Width="856px" AutoGenerateColumns = "false" 
            ShowFooter = "true" ShowHeader="true" BorderStyle="Groove" CaptionAlign="Top" 
            HorizontalAlign="Center" onrowdatabound="GridView1_RowDataBound" &gt;
        &lt;RowStyle BackColor="#F7F6F3" ForeColor="#333333" /&gt;
        &lt;Columns&gt;
            &lt;asp:BoundField HeaderText="ID" /&gt;
            &lt;asp:BoundField HeaderText="First Name" /&gt;
            &lt;asp:BoundField HeaderText="Last Name" /&gt;
            &lt;asp:BoundField HeaderText="Home Phone #" /&gt;
            &lt;asp:BoundField HeaderText="Cell #" /&gt;
            &lt;asp:BoundField HeaderText="Email Address" /&gt;
            &lt;asp:BoundField HeaderText="NIC #" /&gt;
            &lt;asp:TemplateField HeaderText="Action"&gt;
            &lt;ItemTemplate&gt;
                &lt;asp:Button ID="Button1" runat="server" Text="Button" /&gt;
                &lt;asp:Button ID="Button2" runat="server" Text="Button" /&gt;
            &lt;/ItemTemplate&gt;

        &lt;/asp:TemplateField&gt;
    &lt;/Columns&gt;
    &lt;FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" 
         /&gt;
    &lt;PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /&gt;
    &lt;SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /&gt;
    &lt;HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
    &lt;EditRowStyle BackColor="#999999" /&gt;
    &lt;AlternatingRowStyle BackColor="White" ForeColor="#284775" /&gt;
&lt;/asp:GridView&gt;
&lt;/div&gt;

&lt;/form&gt;
&lt;/body&gt;
</code></pre>
