title: populate dropdownlist while clicking on the edit button on datagrid view?-unable to capture the control-null reference
body: <p>I have a gridview with employee ID and an edit button next to it. When clicking on the edit button i need to show a dropdownlist that will populate the data from db.</p>
  
  <pre><code>&lt;asp:GridView ID="grvEmp" runat="server" Width="100%" GridLines="Both" 
      HeaderStyle-BackColor="#999999" AutoGenerateColumns="false"
      OnRowEditing="grvEmp_RowUpdating" OnRowUpdating="grvEmp_RowUpdating"&gt;
  
  &lt;Columns&gt;
  &lt;asp:TemplateField&gt;
  &lt;HeaderTemplate&gt;
  Employee Name
  &lt;/HeaderTemplate&gt;
  &lt;ItemTemplate&gt;
   &lt;%# Eval("EmployeeID")%&gt;
  &lt;/ItemTemplate&gt;
  &lt;EditItemTemplate&gt;
   &lt;asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnLoad="DropDownList1_onload"
      onselectedindexchanged="DropDownList1_SelectedIndexChanged"&gt;
  &lt;/asp:DropDownList&gt;  
  &lt;/EditItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
    &lt;asp:TemplateField HeaderText="Action"&gt;
         &lt;ItemTemplate&gt;
          &lt;asp:Button ID="btnEdit" Text="Edit" runat="server" CommandName="edit" /&gt;&lt;br /&gt;
         &lt;/ItemTemplate&gt;
         &lt;EditItemTemplate&gt;        
         &lt;asp:Button ID="btnUpdate" Text="Update" runat="server" CommandName="Update" /&gt;
       &lt;/EditItemTemplate&gt;
  
         &lt;/asp:TemplateField&gt;
  
  &lt;/Columns&gt;
  
  &lt;HeaderStyle BackColor="#999999" /&gt;
  
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>//Code-behind</p>
  
  <pre><code>protected void grvEmp_RowDataBound(object sender, GridViewRowEventArgs e)
  {
  
      SqlConnection cn = new System.Data.SqlClient.SqlConnection("Data Source=CHANGEME1;Initial Catalog=Reflection;Integrated Security=True");           
      SqlDataAdapter da = new SqlDataAdapter("select salary from employee",cn);
      DataSet ds = new DataSet();
      DropDownList ddl = (DropDownList)e.Row.FindControl("DropDownList1");        //null-unable to capture the control 
      da.Fill(ds);
      cn.Close();
      ddl.DataSource = ds;
      ddl.DataTextField = "salary";
      ddl.DataValueField = "salary";
      ddl.DataBind();
      ddl.Items.Insert(0, new ListItem("--Select--", "0"));
  }
  </code></pre>
  
  <p>but when clicking on the edit button the dropdown list is not populated.
  Can anyone provide an insight on this?</p>