Home All Groups Group Topic Archive Search About

DataGrid & Checkbox Template Columns

Author
13 Feb 2006 2:05 PM
JP
Hi,
I've got a simple datagrid in asp.net (C#) that is populated by an
adapter from SQL.  I
have two template columns - one with a checkbox and one with a textbox.
I am allowing users to indicate which rows to remove from the grid by
checking the boxes - the boxes don't autopostback, i want to remove all
selected rows at once on page postback - my problem is:

I can find now way of iterating through the datagrid rows to check
whether each checkbox in the template column is checked or not!!  Does
anyone know of a way to do this?

Author
14 Feb 2006 5:23 AM
Phillip Williams
If you wire the onCheckedChanged event of the CheckBox server control to a
method then when you postback using any other button the event will be
processed for each row that is checked, e.g.
<asp:CheckBox ID="chkDelete"  title="click here to delete this row"
Runat=server OnCheckedChanged ="DeleteRow"></asp:CheckBox>

For a complete sample code:
http://www.societopia.net/Samples/DataGrid_ChildControlsEvents.aspx

Show quoteHide quote
"JP" wrote:

> Hi,
> I've got a simple datagrid in asp.net (C#) that is populated by an
> adapter from SQL.  I
> have two template columns - one with a checkbox and one with a textbox.
>  I am allowing users to indicate which rows to remove from the grid by
> checking the boxes - the boxes don't autopostback, i want to remove all
> selected rows at once on page postback - my problem is:
>
> I can find now way of iterating through the datagrid rows to check
> whether each checkbox in the template column is checked or not!!  Does
> anyone know of a way to do this?
>
>