I have a web part that has a gridview control on it. I get a data table from a library method I wrote and bind it to the grid. I can either have the grid make the columns with autogeneratcolumns set to true or I can iterate through the data table columns and build the grid columns when the page loads. All that works fine.
I need to add a fake checkbox column and detect which row is checked in a button click and retrieve a column of data from that checked row. I added a checkbox column to the grid in the designer and it is a template column with an edit and item template. I cannot seem to tell if it is checked.
I tried something like the following:
//Iterate through the Rows property
foreach (GridViewRow row in this.GridView1.Rows)
// Access the CheckBox
//tried that too ==> CheckBox cb = (CheckBox)row.FindControl("CheckBox1");
CheckBox cb = row.Cells.Controls as CheckBox;
if (cb != null)
Any ideas on this would be greatly appreciated.