title: Bind Dropdown list in Gridview footer which is in Tab Control
body: <p>I am using ASP.NET and Entity Framework and Tab control of AJAX
   I have a dropdown list control in gridview which is in TAB control   Am not able to bind dropdown list control.
  Tab Control --> Gridview --> Dropdown list
  My ASP.NET Code is</p>
  
  <pre><code>&lt;ajax:TabContainer ID="TabContainer2" runat="server" CssClass="fancy fancy-green"&gt;
                  &lt;ajax:TabPanel ID="TabPanel1" runat="server"&gt;
                      &lt;HeaderTemplate&gt;
                          College Toppers
                      &lt;/HeaderTemplate&gt;
                      &lt;ContentTemplate&gt;
                          &lt;asp:Panel ID="Panel1" runat="server"&gt;
                              &lt;div&gt;
                                  &lt;asp:GridView ID="GridView1" DataKeyNames="TL_ID" runat="server"
                                      AutoGenerateColumns="False" CssClass="Gridview" ShowFooter="True" OnRowDataBound="GRVToppers_RowDataBound"&gt;
                                      &lt;Columns&gt;
                                          &lt;asp:TemplateField&gt;
                                              &lt;EditItemTemplate&gt;
                                                  &lt;asp:ImageButton ID="imgbtnUpdate" CommandName="Update" runat="server" ImageUrl="~/Admin/Images/update.jpg" ToolTip="Update" Height="20px" Width="20px" /&gt;&lt;asp:ImageButton ID="imgbtnCancel" runat="server" CommandName="Cancel" ImageUrl="~/Admin/Images/Cancel.jpg" ToolTip="Cancel" Height="20px" Width="20px" /&gt;
                                              &lt;/EditItemTemplate&gt;
                                              &lt;FooterTemplate&gt;
                                                  &lt;asp:ImageButton ID="imgbtnAdd" runat="server" ImageUrl="~/Admin/Images/AddNewitem.jpg" CommandName="AddNew" Width="30px" Height="30px" ToolTip="Add new User" ValidationGroup="validaiton" /&gt;
                                              &lt;/FooterTemplate&gt;
                                              &lt;ItemTemplate&gt;
                                                  &lt;asp:ImageButton ID="imgbtnEdit" CommandName="Edit" runat="server" ImageUrl="~/Admin/Images/Edit.jpg" ToolTip="Edit" Height="20px" Width="20px" /&gt;&lt;asp:ImageButton ID="imgbtnDelete" CommandName="Delete" runat="server" ImageUrl="~/Admin/Images/delete.jpg" ToolTip="Delete" Height="20px" Width="20px" /&gt;
                                              &lt;/ItemTemplate&gt;
                                          &lt;/asp:TemplateField&gt;
                                          &lt;asp:TemplateField HeaderText="Topper List No"&gt;
                                              &lt;EditItemTemplate&gt;
                                                  &lt;asp:Label ID="lblEditTpid" runat="server" Text='&lt;%#Eval("TL_ID") %&gt;' /&gt;
                                              &lt;/EditItemTemplate&gt;
                                              &lt;ItemTemplate&gt;
                                                  &lt;asp:Label ID="lblShowTpid" runat="server" Text='&lt;%#Eval("TL_ID") %&gt;' /&gt;
                                              &lt;/ItemTemplate&gt;
                                              &lt;ControlStyle Width="10px" /&gt;
                                          &lt;/asp:TemplateField&gt;
                                          &lt;asp:TemplateField HeaderText="Department Name"&gt;
                                              &lt;EditItemTemplate&gt;
                                                  &lt;asp:DropDownList ID="ddlEditDeptname" runat="server" Width="90" DataTextField='&lt;%#Bind("DEPT_NAME") %&gt;' DataValueField='&lt;%#Bind("DEPT_ID") %&gt;' AppendDataBoundItems="true"&gt;&lt;/asp:DropDownList&gt;
                                              &lt;/EditItemTemplate&gt;
                                              &lt;FooterTemplate&gt;
                                                  &lt;asp:DropDownList ID="ddladdnewDeptname" runat="server" Width="90" DataTextField='&lt;%#Bind("DEPT_NAME") %&gt;' DataValueField='&lt;%#Bind("DEPT_ID") %&gt;' AppendDataBoundItems="True"&gt;&lt;/asp:DropDownList&gt;
                                              &lt;/FooterTemplate&gt;
                                              &lt;ItemTemplate&gt;
                                                  &lt;asp:Label ID="lblShowDeptname" runat="server" Text='&lt;%#Eval("DEPT_NAME") %&gt;' Width="90" /&gt;
                                              &lt;/ItemTemplate&gt;
                                              &lt;ControlStyle Width="30px" /&gt;
                                          &lt;/asp:TemplateField&gt;
                                      &lt;/Columns&gt;
                                      &lt;HeaderStyle BackColor="#61A6F8" Font-Bold="True" ForeColor="White"&gt;&lt;/HeaderStyle&gt;
                                  &lt;/asp:GridView&gt;
                              &lt;/div&gt;
                          &lt;/asp:Panel&gt;
                      &lt;/ContentTemplate&gt;
                  &lt;/ajax:TabPanel&gt;
  &lt;/ajax:TabContainer&gt;
  </code></pre>
  
  <p>==================
  My C# code is</p>
  
  <pre><code>protected void GRVToppers_RowDataBound(object sender, GridViewRowEventArgs e)
          {
              try
              {
                  var dept = from n in ecme.DEPT_MASTER
                             select new { n.DEPT_ID, n.DEPT_NAME };
                  DropDownList ddl = null;
                  if (e.Row.RowType == DataControlRowType.Footer)
                  {
                      ddl = e.Row.FindControl("ddladdnewDeptname") as DropDownList;
                      int cnt = 0;
  
                      cnt = dept.Count();
                      ListItem[] items = new ListItem[cnt];
                      for (int i = 0; i &lt; cnt; i++)
                      {
                           items[i] = new ListItem("DEPT_NAME", "DEPT_ID");
                      }
                  }
              }
              catch (Exception)
              { }
          }
  </code></pre>
  
  <p>========================</p>