Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
400
Iterate child rows in WHDG
posted

Hello,

I've added an unboundcheckboxfield to my WebHierarchicalDataGrid child rows and trying to access each after a button click.  Because of the way the checkbox field was added, I don't know what the ID of the control is:

Here's how the checkbox is added:

InventoryGrid.Bands.Add(childBand);

UnboundCheckBoxField cbf = new UnboundCheckBoxField();
cbf.Key = "ID";
cbf.Width = 25;
InventoryGrid.Bands[0].Columns.Add(cbf);
InventoryGrid.Bands[0].AutoGenerateColumns = false;

Here's my button click event:

foreach (ContainerGridRecord gridRow in InventoryGrid.GridView.Rows)
{
if (gridRow.HasRowIslands)
{
ContainerGridRecordCollection childRows = gridRow.RowIslands[0].Rows;
//If the current row has RowIslands, iterate through row island rows
foreach (ContainerGridRecord row in childRows)
{
CheckBox cb = (CheckBox)row.Items[2].FindControl("CheckBox1");
cb.Checked = true;
}
}
}

I can loop through all the rows and child rows, but how can I find a control without knowing the name or ID?  I need to find all the rows where the checkbox is checked.

Thank you,

Steve