title: Telerik Radgrid : adding another footer row
body: <p>I need to add multiple footer rows to my <code>RadGrid</code> instance ; for the moment, however, I just want to add second one. I have currently a single footer row and it's working and displaying perfectly, for the record.</p>
  
  <p>I found <a href="http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-with-3-footers.aspx" rel="nofollow">the following relevant question</a> on the Telerik forums and tried implemeting it but it's not working : the code gets executed, and the new <code>FooterItem</code> gets added to the <code>Controls</code> but that second row just doesn't appear. I need to find out why and I'd be grateful if anyone could help me fix that problem.</p>
  
  <p><strong>ASP grid code</strong></p>
  
  <pre><code>&lt;div id="OrderMainContent"&gt;
      &lt;telerik:RadAjaxManager runat="server" ID="RadAjaxManager1"&gt;
          &lt;AjaxSettings&gt;
              &lt;telerik:AjaxSetting AjaxControlID="RadGrid1" /&gt;
              &lt;telerik:AjaxSetting AjaxControlID="txtQuantity"&gt;
                  &lt;UpdatedControls&gt;
                      &lt;telerik:AjaxUpdatedControl ControlID="RadGrid1" /&gt;
                  &lt;/UpdatedControls&gt;
              &lt;/telerik:AjaxSetting&gt;
          &lt;/AjaxSettings&gt;
      &lt;/telerik:RadAjaxManager&gt;
      &lt;telerik:RadInputManager ID="RadInputManager1" runat="server"&gt;
          &lt;telerik:NumericTextBoxSetting BehaviorID="NumericBehavior1" Type="Number" DecimalDigits="0"&gt;
              &lt;TargetControls&gt;
                  &lt;telerik:TargetInput ControlID="RadGrid1" /&gt;
              &lt;/TargetControls&gt;
          &lt;/telerik:NumericTextBoxSetting&gt;
      &lt;/telerik:RadInputManager&gt;
      &lt;telerik:RadGrid ID="RadGrid1" runat="server" Skin="Sunset" AllowSorting="True" AutoGenerateColumns="False"
          GridLines="None" ShowFooter="True" OnItemDataBound="RadGrid1_ItemDataBound" OnPreRender="RadGrid1_PreRender"&gt;
          &lt;MasterTableView DataKeyNames="ProductID" TableLayout="Fixed"&gt;
              &lt;RowIndicatorColumn&gt;
                  &lt;HeaderStyle Width="20px"&gt;&lt;/HeaderStyle&gt;
              &lt;/RowIndicatorColumn&gt;
              &lt;ExpandCollapseColumn&gt;
                  &lt;HeaderStyle Width="20px"&gt;&lt;/HeaderStyle&gt;
              &lt;/ExpandCollapseColumn&gt;
              &lt;Columns&gt;
                  &lt;telerik:GridBoundColumn UniqueName="colProduct" HeaderText="&lt;%$ Resources: SiteLabels, ProductOrderForm.lblProduct %&gt;"
                      HeaderStyle-HorizontalAlign="Center" DataField="ProdDesc"&gt;
                      &lt;HeaderStyle HorizontalAlign="Center"&gt;&lt;/HeaderStyle&gt;
                  &lt;/telerik:GridBoundColumn&gt;
                  &lt;telerik:GridTemplateColumn UniqueName="colQuantity" HeaderText="&lt;%$ Resources: SiteLabels, ProductOrderForm.lblQuantity %&gt;"
                      HeaderStyle-HorizontalAlign="Center" DataField="OrderQty" ColumnEditorID="txtQuantity"&gt;
                      &lt;HeaderStyle Width="90" /&gt;
                      &lt;ItemStyle Width="90px" /&gt;
                      &lt;ItemTemplate&gt;
                          &lt;asp:TextBox ID="txtQuantity" runat="server" Width="50px" OnTextChanged="txtQuantity_TextChanged"
                              AutoPostBack="true"&gt;
                          &lt;/asp:TextBox&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/telerik:GridTemplateColumn&gt;
                  &lt;telerik:GridTemplateColumn UniqueName="colPrice" HeaderText="&lt;%$ Resources: SiteLabels, ProductOrderForm.lblBasePrice %&gt;"
                      HeaderStyle-HorizontalAlign="Center" DataField="ProdUnitPrice"&gt;
                      &lt;HeaderStyle Width="80px" /&gt;
                      &lt;ItemStyle Width="80px" /&gt;
                      &lt;ItemTemplate&gt;
                          &lt;asp:Label ID="lblPrice" runat="server" Text='&lt;%# Eval("ProdUnitPrice") %&gt;' /&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/telerik:GridTemplateColumn&gt;
                  &lt;telerik:GridBoundColumn UniqueName="colNotes" HeaderText="&lt;%$ Resources: SiteLabels, ProductOrderForm.lblNotes %&gt;"
                      HeaderStyle-HorizontalAlign="Center"&gt;
                      &lt;HeaderStyle Width="200px" /&gt;
                      &lt;ItemStyle Width="200px" /&gt;
                  &lt;/telerik:GridBoundColumn&gt;
              &lt;/Columns&gt;
          &lt;/MasterTableView&gt;
          &lt;ClientSettings&gt;
              &lt;Scrolling AllowScroll="True" UseStaticHeaders="True" /&gt;
          &lt;/ClientSettings&gt;
      &lt;/telerik:RadGrid&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Relevant code behind</strong></p>
  
  <pre><code>    protected void RadGrid1_PreRender(object sender, EventArgs e)
      {
          AddFooterRow(sender as RadGrid);
      }
  
      private void AddFooterRow(RadGrid grid)
      {
          if (grid != null)
          {
              GridItem[] footerItems = grid.MasterTableView.GetItems(GridItemType.Footer);
  
              if (footerItems.Count() == 1)
              {
                  GridTFoot foot = footerItems[0].Parent.Controls[0].Parent as GridTFoot;
  
                  for (int i = 0; i &lt; foot.Controls.Count; i++)
                  {
                      GridFooterItem item = foot.Controls[i] as GridFooterItem;
  
                      if(item != null)
                      {
                          lastFooterPos = i;
                          break;
                      }
                  }
  
                  GridFooterItem existingFooter = foot.Controls[lastFooterPos] as GridFooterItem;
                  GridFooterItem newFooterItem = new GridFooterItem(grid.MasterTableView, 0, 0);
  
                  foreach(TableCell fc in existingFooter.Cells)
                  {
                      TableCell newFooterCell = new TableCell();
                      newFooterCell.Text = "allo";
                      newFooterItem.Cells.Add(newFooterCell);
                  }
  
                  foot.Controls.AddAt(lastFooterPos + 1, newFooterItem);
              }
          }
      }
  </code></pre>
  
  <p>Of course if you need more precisions, just ask. Thank you for your help.</p>