Question

I'm trying to write content to an items' Group Footer on an item's ItemDataBound event. Anyone have any idea how to access an Item's group footer from the Item itself? In other words, how would I get an item's associated group footer from the item object as it's being bound?

protected void grid_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;

            **GridItemGroupFooter footer = item.GroupFooter** <-- Pseudocode for what I want to do
        }
    }
Was it helpful?

Solution

you should do it like this

if (e.Item is GridFooterItem)
{
  itemtype somenameforitem=(itemtype )grid.FooterRow.FindControl("youritemid");
  //for ex if you need textbox then it will be like this
  //TextBox texte=(TextBox)gridname.FooterRow.FindControl("textboxid");
}

also you can do it like this.

GridFooterItem footerItem = (GridFooterItem)grid.MasterTableView.GetItems(GridItemType.Footer)[0];
TextBox texte=(TextBox)footerItem.FindControl("textboxid");//accessing Button inside FooterTemplate

I have give the index [0] while getting the grid footer item as the text box is one and only item in my grid footer, if you have multiple footer items, you can give the index of the item you wan to find

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top