title: Dropdown does not populate when last item deleted from gridview
body: <p>I am having trouble determining where the bug is for this problem.
  I have an ASP.NET Master.Page web application that has a Gridview.  I am using the jquery-chosen plugin for a dropdown list in the EmptyDataTemplate (or FooterControl if there is data).</p>
  
  <p>On initialization if there is no data for the grid, the dropdown is populated and displays correctly. If the grid has items in it and I delete all of them, so that there is no data, the dropdown does not display any data.  The DataBound event is called and the DataTable has all of the correct data in it. It is bound to the dropdown.  But do items appear in the list.
  This is my markup:</p>
  
  <pre><code>&lt;div id="DelegateGridWrapper"&gt;
      &lt;asp:GridView ID="DelegateInfoGridView" runat="server" 
          AutoGenerateColumns="false" Caption="Delegate Information" 
          CaptionAlign="Top" CssClass="grid" RowStyle-Wrap="true" 
          HorizontalAlign="Left" ShowFooter="true" 
          AllowPaging="true" PageSize="5"  ShowHeaderWhenEmpty="false" onrowediting="DelegateInfoGridView_RowEditing" 
          onrowcancelingedit="DelegateInfoGridView_RowCancelingEdit" onrowdeleting="DelegateInfoGridView_RowDeleting" 
          onrowupdating="DelegateInfoGridView_RowUpdating" 
          ondatabound="DelegateInfoGridView_DataBound" 
          onrowcommand="DelegateInfoGridView_RowCommand"&gt;
          &lt;Columns&gt;
               &lt;asp:TemplateField HeaderText="Recipient ID"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="deligvLblRecipientID" runat="server" Text='&lt;%# Bind("RecipientID") %&gt;'&gt;&lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;
               &lt;/asp:TemplateField&gt;
  
               &lt;asp:TemplateField HeaderText="Delegate" ItemStyle-Wrap="false"&gt; 
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="deligvLblRecipientName" runat="server" Text='&lt;%# Bind("RecipientName") %&gt;'&gt;&lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;
                  &lt;FooterTemplate&gt;
                      &lt;asp:DropDownList ID="deligvDDLRecipientName" runat="server" ClientIDMode="Static"
                                          data-placeholder="Choose delegate…" class="chosen-single"&gt;
                      &lt;/asp:DropDownList&gt;
                  &lt;/FooterTemplate&gt;
               &lt;/asp:TemplateField&gt;
               &lt;asp:TemplateField HeaderText="Active"&gt; 
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="deligvLblActive" runat="server" Text='&lt;%# (Boolean.Parse(Eval("Active").ToString())) ? "Yes" : "No" %&gt;'&gt;&lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;         
                   &lt;EditItemTemplate&gt;
                      &lt;asp:DropDownList ID="deligvDDLActive" runat="server" Text='&lt;%# (Boolean.Parse(Eval("Active").ToString())) ? "Yes" : "No" %&gt;'&gt;
                          &lt;asp:ListItem&gt;Yes&lt;/asp:ListItem&gt;
                          &lt;asp:ListItem&gt;No&lt;/asp:ListItem&gt;
                      &lt;/asp:DropDownList&gt;
                  &lt;/EditItemTemplate&gt; 
                  &lt;FooterTemplate&gt;
                      &lt;asp:DropDownList ID="deligvDDLActiveInsert" runat="server"&gt;
                          &lt;asp:ListItem Selected="True"&gt;Yes&lt;/asp:ListItem&gt;
                          &lt;asp:ListItem&gt;No&lt;/asp:ListItem&gt;
                      &lt;/asp:DropDownList&gt;
                  &lt;/FooterTemplate&gt;                         
              &lt;/asp:TemplateField&gt;
              &lt;asp:TemplateField HeaderText="Action" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Center"&gt;
                   &lt;ItemTemplate&gt;
                      &lt;asp:Button ID="deligvEditButton" runat="server" CausesValidation="False" CommandName="Edit" 
                                  Text="Edit" CssClass="gridActionbutton"&gt;
                      &lt;/asp:Button&gt;
                      &amp;nbsp;&lt;asp:Button ID="deligvDeleteButton" runat="server" CausesValidation="False" CommandName="Delete" ClientIDMode="Static" 
                                  Text="Delete" CssClass="gridActionbutton"  OnClientClick="return confirm('Are you sure you want to delete this Delegate Information?')" &gt;
                      &lt;/asp:Button&gt;
                  &lt;/ItemTemplate&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:Button ID="deligvUpdateButton" runat="server" CausesValidation="False" CommandName="Update" 
                                      Text="Update" CssClass="gridActionbutton"&gt;&lt;/asp:Button&gt;
                      &amp;nbsp;&lt;asp:Button ID="deligvCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" 
                                      Text="Cancel" CssClass="gridActionbutton"&gt;&lt;/asp:Button&gt;
                  &lt;/EditItemTemplate&gt;
                  &lt;FooterTemplate&gt;
                      &lt;asp:Button ID="deligvAddButton" runat="server" CommandName="Add" Text="Add Delegate" Width="90%" CausesValidation="false" 
                                  CssClass="gridActionbutton"&gt;
                      &lt;/asp:Button&gt;
                  &lt;/FooterTemplate&gt;
              &lt;/asp:TemplateField&gt;
          &lt;/Columns&gt;
          &lt;EmptyDataTemplate&gt;
              &lt;tr&gt;
                  &lt;th&gt;Recipient ID&lt;/th&gt;
                  &lt;th&gt;Delegate&lt;/th&gt;
                  &lt;th&gt;Active&lt;/th&gt;
                  &lt;th&gt;Action&lt;/th&gt;
              &lt;/tr&gt;
              &lt;tr&gt; 
                  &lt;td colspan="4" style="text-align:center;"&gt;
                      No Delegates were found for you. Delegates can be added by clicking the 'Add Delegate' Button.
                  &lt;/td&gt; 
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:DropDownList ID="deligvDDLRecipientName" runat="server" ClientIDMode="Static" 
                                          data-placeholder="Choose delegate…" class="chosen-single"&gt;
                      &lt;/asp:DropDownList&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                       &lt;asp:DropDownList ID="deligvDDLActiveInsert" runat="server"&gt;
                          &lt;asp:ListItem Selected="True"&gt;Yes&lt;/asp:ListItem&gt;
                          &lt;asp:ListItem&gt;No&lt;/asp:ListItem&gt;
                      &lt;/asp:DropDownList&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:Button ID="deligvAddButtonEmpty" runat="server" CommandName="Add" Text="Add Delegate" Width="90%" CausesValidation="false" 
                          CssClass="gridActionbutton"&gt;
                      &lt;/asp:Button&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/EmptyDataTemplate&gt;
       &lt;/asp:GridView&gt;
  </code></pre>
  
  <p></p>
  
  <p>This is my DataBound event:</p>
  
  <pre><code> protected void DelegateInfoGridView_DataBound(object sender, EventArgs e)
      {
          try
          {
  
              m_strUserID = CommonMethods.ParseUserID(User.Identity.Name);
  
              //Get the Footer controls that have the new entry data
              Control tFooterControls = getFooterControls(DelegateInfoGridView);
              DropDownList ddlRecipientNames = tFooterControls.FindControl("deligvDDLRecipientName") as DropDownList;              
              m_strXmlTableData = m_pagingClient.GetAllPossibleDelegates(m_strUserID);
              DataTable tdtAllDelegates = CommonMethods.ParseXML(m_strXmlTableData);
              ddlRecipientNames.DataSource = tdtAllDelegates;
              ddlRecipientNames.DataTextField = "RecipientName";
              ddlRecipientNames.DataValueField = "RecipientID";
              ddlRecipientNames.DataBind();
              ddlRecipientNames.Items.Insert(0, new ListItem("", "0"));//This is needed for the jquery-chosen dropdown to add data-holder text
          }
          catch (Exception ex)
          {
              //TO DO: Response.Redirect("~/Error.aspx");
          }
      }
  </code></pre>
  
  <p>Why won't the dropdown display the items after all items are deleted but will correctly display if initially there are no items in the gridview to display?
  I tried triggering an update for the chosen dropdown but that is called initially, before the data is retrieved.
  I don't know if there is a bug in the code-behind or do I need to add something in the javascript.</p>
  
  <p>Thanks.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The problem is not with the chosen plugin.  I removed the attribute from the DropDown list that changes it to a 'chosen' style and the problem still exists.  So the asp:DropDownList will not populate after the user deletes all of the items in the grid.  But if the grid is initialized with no items, the DropDown is correctly populated.</p>
  
  <p><strong>UPDATE</strong>
  I got a suggestion to use the 'RowDeleted' event to bind the dropdown.  However, the event is not firing.  I added the event to the markup:</p>
  
  <pre><code>onrowdeleted="DelegateInfoGridView_RowDeleted"
  </code></pre>
  
  <p>This is the event that is never called:</p>
  
  <pre><code> protected void DelegateInfoGridView_RowDeleted(object sender, GridViewDeletedEventArgs e)
      {
          try
          {
              m_strUserID = CommonMethods.ParseUserID(User.Identity.Name);
  
              //Get the Footer controls that have the new entry data
              Control tFooterControls = getFooterControls(DelegateInfoGridView);
              DropDownList tddlRecipientNames = tFooterControls.FindControl("deligvDDLRecipientName") as DropDownList;
              m_strXmlTableData = m_pagingClient.GetAllPossibleDelegates(m_strUserID);
              DataTable tdtAllDelegates = CommonMethods.ParseXML(m_strXmlTableData);
              tddlRecipientNames.DataSource = tdtAllDelegates;
              tddlRecipientNames.DataTextField = "RecipientName";
              tddlRecipientNames.DataValueField = "RecipientID";
              tddlRecipientNames.DataBind();
              tddlRecipientNames.Items.Insert(0, new ListItem("", "0"));//This is needed for the jquery-chosen dropdown to add data-holder text
          }
          catch (Exception ex)
          {
              //TO DO: Response.Redirect("~/Error.aspx");
          }
      }
  </code></pre>
  
  <p>What is different about the RowDeleted event that it will not fire?</p>