all groups > asp.net webcontrols > october 2005 >
You're in the

asp.net webcontrols

group:

Checkbox in datagrid


RE: Checkbox in datagrid Phillip Williams
10/30/2005 1:16:03 PM
asp.net webcontrols: Upon submit you can either
1) loop through the entire datagrid items collection:
foreach (DataGridItem item in dgAddresses)
{
switch (item.ItemType )
{
case ListItemType.Item:
//find the individual controls
break;
}
}

2) use the event handler of the checkbox as the entry point to process the
row that was selected as in this example:
http://www.societopia.net/Samples/DataGrid_ChildControlsEvents.aspx

In both cases you can get the datarow that was selected from the datagrid
item (let's call it dgItem) by a formula such as:
DataRow dr = dt.Rows.Find(DataGrid1.DataKeys(dgItem.ItemIndex));
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


[quoted text, click to view]
Checkbox in datagrid Tommy
10/30/2005 2:57:27 PM
I have a datagrid with a checkbox in one col. It's bound to a row in my
table.

I need to allow my user to select multiple records then process each one
when they click a button.

How can i iterate through each row in my grid and check the checkbox's
checked property? I have my pk hidden in the grid so I can use it to pass to
my stored proc. I just can't seem to iterate through and check each control

Ultimately it would be nice to be able to get the datarow for each row that
is bound to the grid and check the fields but i'm sure that's a little much
to ask.

Thanks for any tips.

Tommy

AddThis Social Bookmark Button