Inserting Items in to the Footer

5 posts, 1 answers
  1. Danny
    Danny avatar
    35 posts
    Member since:
    May 2012

    Posted 23 Oct 2012 Link to this post

    Hello all-

    is there a way to assign values to footer items using an integer index?

    If so, in what event would you do this?

    Thanks in advance.
  2. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 26 Oct 2012 Link to this post

    Hello Danny,

    If you want to change the RadGrid footer item you need to handle ItemCreated event and check if e.Item is GridFooterItem. Then you could change its cells by using the columns UniqueName. For example:
    void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
          GridFooterItem footerItem = e.Item as GridFooterItem;
          if (footerItem != null)
          {
              footerItem["columnUniqueName"].Text = "SomeValue";
          }
    }
    However if you want to change the GroupFooterItems you could try using the same approach or you could try using the GroupFooterTemplate. Online example of GroupFooterTemplate you could find here:
    http://demos.telerik.com/aspnet-ajax/grid/examples/groupby/headerandfootertemplates/defaultcs.aspx

    I hope this helps.

    All the best,
    Radoslav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Danny
    Danny avatar
    35 posts
    Member since:
    May 2012

    Posted 26 Oct 2012 Link to this post

    Thanks for the reply, Radoslav.

    In gridview I'm able to add items to the footer in the OnRowDataBound event like this:
    protected void gridview_OnRowDataBound(object sender, GridViewRowEventArgs e)
           {
               if (e.Row.RowType == DataControlRowType.Footer)
               {                         
                   for(int i = 0; i < dt.columns.count; i++)
                   {
                         e.Row.Cells[i].Text = someString[i];

    So there's no way to assign the cells in the footer as integer indexes?  I have to use the column names?
  5. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 29 Oct 2012 Link to this post

    Hi,

    You can assign values to footer items using an integer index. But the column index starts at index '2' because GridExpandColumn and GridRowindicatorColumn are always in front of data columns. So the most recommended way is to change the value by using the column's UniqueName. Here is the sample code snippet I tried to assign footer cell text using index.

    C#:
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridFooterItem)
        {
            string[] arr2 = { "one", "two", "three" };
            for (int i = 0; i < dt1.Columns.Count; i++)
            {
               int j = i + 2;
               e.Item.Cells[j].Text = arr2[i];
               j++;
            }    
        }
    }

    Thanks,
    Shinu.
  6. Danny
    Danny avatar
    35 posts
    Member since:
    May 2012

    Posted 29 Oct 2012 Link to this post

    This-

    "But the column index starts at index '2' because GridExpandColumn and GridRowindicatorColumn are always in front of data columns"

    Thanks Shinu!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017