ASP.NET GridView Update/Overall Query Structure
<p>New Question.
I have this as my gridview and I want to have it so when the page loads the grid view is filled with the database information.</p>

<p>So below is the code for the gridview. and below that is the c# code.</p>

<p>UPDATE</p>

<pre><code>&lt;asp:GridView ID="RegistrantsView" runat="server" AllowPaging="True" 
                 AllowSorting="True" AutoGenerateColumns="True" 
                 CellPadding="4" 
                 ForeColor="#333333" GridLines="None"&gt;
                 &lt;AlternatingRowStyle BackColor="White" ForeColor="#284775" /&gt;
                 &lt;EditRowStyle BackColor="#999999" /&gt;
                 &lt;FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
                 &lt;HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
                 &lt;PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /&gt;
                 &lt;RowStyle BackColor="#F7F6F3" ForeColor="#333333" /&gt;
                 &lt;SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /&gt;
                 &lt;SortedAscendingCellStyle BackColor="#E9E7E2" /&gt;
                 &lt;SortedAscendingHeaderStyle BackColor="#506C8C" /&gt;
                 &lt;SortedDescendingCellStyle BackColor="#FFFDF8" /&gt;
                 &lt;SortedDescendingHeaderStyle BackColor="#6F8DAE" /&gt;
             &lt;/asp:GridView&gt;
</code></pre>

<p>C#:</p>

<pre><code>SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["FFL-New DataConnectionString"].ConnectionString);

protected void Page_Load(object sender, EventArgs e)
{
    connection.Open();//opens connection on page load
    SqlCommand selectAllCommand = new SqlCommand();
    selectAllCommand.CommandText = "select * from registrants";
    selectAllCommand.Connection = connection;

    SqlDataAdapter sda = new SqlDataAdapter();
    sda.SelectCommand = selectAllCommand;

    DataTable dt = new DataTable();
    sda.Fill(dt);

    RegistrantsView.DataSource = dt;
    RegistrantsView.DataBind();
}
</code></pre>
