ASP.NET control in GridView not found to exist in code behind
<p>I have a DropDownList that I would like to populate with column values from a DataBase. However, when I try to bind the DropDownList in code behind, the IDE keeps telling me:</p>

<p>"The name 'EqpCatDDL' does not exist in the current context"</p>

<p>I am not sure what is going on since I referred to the control by its ID. The following is the code:</p>

<p>aspx:</p>

<pre><code>&lt;asp:GridView ID="Gridview1" runat="server" ShowFooter="true" 
                AutoGenerateColumns="false" 
                &gt;
                &lt;Columns&gt;
                    &lt;asp:BoundField DataField="S/N" HeaderText="S/N" /&gt;
                    &lt;asp:TemplateField HeaderText="Item Name"&gt;
                        &lt;ItemTemplate&gt;
                            &lt;asp:DropDownList ID="EqpCatDDL" runat="server"&gt;&lt;/asp:DropDownList&gt;
                        &lt;/ItemTemplate&gt;
                    &lt;/asp:TemplateField&gt;
                    &lt;asp:TemplateField HeaderText="Description"&gt;
                        &lt;ItemTemplate&gt;
                            &lt;asp:DropDownList ID="DescripDDL" runat="server"&gt;
                            &lt;/asp:DropDownList&gt;
                        &lt;/ItemTemplate&gt;
                    &lt;/asp:TemplateField&gt;
                    &lt;asp:TemplateField HeaderText="Quantity"&gt;
                        &lt;ItemTemplate&gt;
                            &lt;asp:TextBox ID="TextBox3" runat="server"&gt;&lt;/asp:TextBox&gt;
                        &lt;/ItemTemplate&gt;
                    &lt;/asp:TemplateField&gt;
                    &lt;asp:TemplateField HeaderText="Remarks"&gt;
                        &lt;ItemTemplate&gt;
                            &lt;asp:TextBox ID="TextBox4" runat="server"&gt;&lt;/asp:TextBox&gt;
                        &lt;/ItemTemplate&gt;
                        &lt;FooterStyle HorizontalAlign="Right" /&gt;
                        &lt;FooterTemplate&gt;
                            &lt;asp:Button ID="ButtonAdd" onclick="ButtonAdd_Click" runat="server" Text="Add New Row" /&gt;
                        &lt;/FooterTemplate&gt;
                    &lt;/asp:TemplateField&gt;
                &lt;/Columns&gt;
            &lt;/asp:GridView&gt;
</code></pre>

<p>c#:</p>

<pre><code>    public void Populate1()
{
    string connString = ConfigurationManager.ConnectionStrings["MyDbConn"].ConnectionString;
    SqlConnection connection = new SqlConnection(connString);

    SqlCommand cmd = new SqlCommand("SELECT EqpCateID, EqpCat FROM EqpCategory", connection);
    cmd.Connection.Open();

    SqlDataReader ddlValues;
    ddlValues = cmd.ExecuteReader();

    EqpCatDDL.DataSource = ddlValues;
    EqpCatDDL.DataValueField = "EqpCateID";
    EqpCatDDL.DataTextField = "EqpCat";
    EqpCatDDL.DataBind();

    cmd.Connection.Close();
    cmd.Connection.Dispose();
}
protected void Page_Load(object sender, EventArgs e)
{
    Populate1(); 
}
</code></pre>

<p>The IDE can't find the EqpCatDDL control.</p>

<p>I am using the following: Visual Studio 2010, Microsoft SQL Server Management Studio 2008</p>

<p>I am working with a Visual Studio website</p>