title: I am getting null when I am using (DropDownList)e.Row.FindControl
body: <p><strong>Here is my code where it's giving the value of ddl = null:</strong></p>
  
  <pre><code>//event handler to bind the data to the row before rendering the gridview
  protected void gridview1_RowDataBound(object sender ,GridViewRowEventArgs e)
  {
      if ((e.Row.RowType == DataControlRowType.DataRow)&amp;&amp;(e.Row.DataItem!=null))
      {
          //DropDownList ddlNo = (DropDownList)e.Row.FindControl("ddlNo");
          DropDownList ddlNo = (DropDownList)e.Row.FindControl("ddlNo");
  
          if (ddlNo != null)
          {
              ddlNo.DataSource = Test.GetData();
              ddlNo.DataBind();
              ddlNo.SelectedValue = gridview1.DataKeys[e.Row.RowIndex].Values[0].ToString();//datakeys are used to retain the value of the no. in edit mode    
          }
      }
  }
  </code></pre>
  
  <p><strong>Here is my aspx code:</strong></p>
  
  <pre><code>&lt;asp:GridView ID="gridview1" runat="server" AutoGenerateColumns="false" AutoGenerateDeleteButton="false" AutoGenerateEditButton="false" ShowFooter="true" EmptyDataText="No data available." PagerStyle-HorizontalAlign="Right" AllowPaging="true" AllowSorting="true" GridLines="Vertical" Width="98%" EnableViewState="true" OnRowCancelingEdit="gridview1_RowCancelingEdit" OnRowDataBound="gridview1_RowDataBound" OnRowEditing="gridview1_RowEditing" OnRowUpdating="gridview1_RowUpdating" OnRowCommand="gridview1_RowCommand" OnRowDeleting="gridview1_RowDeleting" DataKeyNames="testID"&gt;
      &lt;Columns&gt;
          &lt;asp:TemplateField HeaderText="Select" HeaderStyle-HorizontalAlign="Left"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="lblSelect" runat="server" Text="Select"&gt;&lt;/asp:Label&gt;
                  &lt;%-- &lt;asp:CheckBox ID="chkSelect" runat="server" AutoPostBack="true" OnCheckedChanged="chkSelect_CheckChanged" /&gt;--%&gt;
              &lt;/ItemTemplate&gt;
              &lt;HeaderStyle HorizontalAlign="Left" /&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:BoundField DataField="testID" HeaderText="SearchId" /&gt;
          &lt;asp:TemplateField HeaderText="Name" HeaderStyle-HorizontalAlign="Left"&gt;
              &lt;EditItemTemplate&gt;
                  &lt;asp:TextBox ID="txtName" runat="server" Text='&lt;%#Eval("testDesc") %&gt;' /&gt;
              &lt;/EditItemTemplate&gt;
              &lt;FooterTemplate&gt;
                  &lt;asp:TextBox ID="txtNewName" runat="server"&gt;&lt;/asp:TextBox&gt;
              &lt;/FooterTemplate&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="lblName" runat="server" Text='&lt;%# Bind("testDesc") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
              &lt;HeaderStyle HorizontalAlign="Left" /&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="No." HeaderStyle-HorizontalAlign="Left"&gt;
              &lt;EditItemTemplate&gt;
                  &lt;asp:DropDownList ID="ddlNo" runat="server" DataTextField="testNo" DataValueField="testNo" /&gt;
              &lt;/EditItemTemplate&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="lblNo" runat="server" Text='&lt;%# Bind("testNo") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
              &lt;FooterTemplate&gt;
                  &lt;asp:DropDownList ID="ddlNewNo" runat="server" DataTextField="testNo" DataValueField="testNo"&gt;
                  &lt;/asp:DropDownList&gt;
              &lt;/FooterTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Edit" ShowHeader="False"&gt;
              &lt;EditItemTemplate&gt;
                  &lt;asp:LinkButton ID="linkbt1" runat="server" CausesValidation="true" CommandName="Update" Text="Update"&gt;
                  &lt;/asp:LinkButton&gt;
                  &lt;asp:LinkButton ID="linkbt2" runat="server" CausesValidation="false" CommandName="Cancel" Text="Cancel"&gt;&lt;/asp:LinkButton&gt;
              &lt;/EditItemTemplate&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:LinkButton ID="linkbt1" runat="server" CausesValidation="false" CommandName="Edit" Text="Edit"&gt;
  
                  &lt;/asp:LinkButton&gt;
              &lt;/ItemTemplate&gt;
              &lt;FooterTemplate&gt;
                  &lt;asp:LinkButton ID="linkbt2" runat="server" CausesValidation="false" CommandName="AddNew" Text="AddNew"&gt;
  
                  &lt;/asp:LinkButton&gt;
              &lt;/FooterTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:CommandField HeaderText="Delete" ShowDeleteButton="true" ShowHeader="true" /&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Can anyone provide a relevant solution to this?</p>