I have a grid with a that I dynamically created a checkbox on the Group Header. I am trying to toggle the checkboxes in the data item to check or uncheck the group checkbox. The code below is selecting the Header checkbox and not the group checkbox. How can I acheive this?
protected void ToggleRowSelection(object sender, EventArgs e)
{
((sender as CheckBox).NamingContainer as GridItem).Selected = (sender as CheckBox).Checked;
bool checkHeader = true;
foreach (GridDataItem dataItem in rgvFunctions.MasterTableView.Items)
{
if (!(dataItem.FindControl("isFunction") as CheckBox).Checked)
{
checkHeader = false;
break;
}
}
GridHeaderItem headerItem = rgvFunctions.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem;
(headerItem.FindControl("CheckAll") as CheckBox).Checked = checkHeader;
}