This is a migrated thread and some comments may be shown as answers.

GridGroupFooterItem

2 Answers 155 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Luis
Top achievements
Rank 1
Luis asked on 10 Apr 2012, 09:56 PM
Hello, I'm trying to add, dynamically, a radbutton to the GroupFooterItem and this button needs to have some values in the commandname and commandargument. These values are related to the cells from a group in the grid. So far I have been able to add those buttons with the OnPreRender event, but I'm stuck on how to set those values with a specific cell in the group.

I have thought about querying db again and use foreach to assign the appropiate values, but I think this scenario is error prone, so leaving it as a last resource.

any pointers???

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 11 Apr 2012, 11:08 AM
Hello Luis,

Try the following code to pass the cell value as command argument for button.
C#:
string value;
protected
void RadGrid1_PreRender(object sender, EventArgs e)
{
 foreach (GridGroupHeaderItem groupHeader in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader))
 {
  int count = 0;
  GridItem[] children = groupHeader.GetChildItems();
  foreach (GridDataItem child in children)//looping through to retrieve cell value
  {
     GridDataItem childItem = child as GridDataItem;
     value = childItem["LastName"].Text;
     count++;
  }
 }
 GridGroupFooterItem item = (GridGroupFooterItem)RadGrid1.MasterTableView.GetItems(GridItemType.GroupFooter)[0];
 Button btn = new Button();
 btn.ID = "Button1";
 btn.Text = "Delete";
 btn.CommandArgument = value;
 item.Cells[0].Controls.Add(btn);
}

Thanks,
Princy.
0
Luis
Top achievements
Rank 1
answered on 16 Apr 2012, 06:08 PM
Thaks Princy, it worked great...
Tags
Grid
Asked by
Luis
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Luis
Top achievements
Rank 1
Share this question
or