aspx thread: Re: Referencing an asp:Checkbox contorl to a row (item) in a datagrid
Did you find a solution to this?
I'm stuck on the same problem with checkboxes
> Dear Experts,
>
> I use a DataGrid to diplay the contents of a database table on a .aspx
> site. I added a column, bearing a checkbox, to select items out of the
> DataGrid.
>
> I tried to use an event handler to react to every click at the
checkboxes.
> When an item (row of the DataGird) is selected / deselected, the
> coresponding item should be stored /deleted immediately in a separate
> database.
>
> The problem is, that I am not able to get a reference from the checkbox
to
> the corresponding datarow of the datagrid, when the "oncheckedchanged"
> event of the checkbox is fired. My first idea was to use the ID of the
> checkboxes, but the checkboxes in the different rows of the datagrid
have
> all the same ID, as defined at the ItemTemplate within
the "<ASP:DataGrid"
> tag.
>
> Is there any other (hopefully comfortable) way to reference to a row
> within a datagrid, or an other event (maybe a helpful DataGrid event)? I
> already tried the OnItemCommand event of the datagrid, but this seems to
> work only with command buttons and not with checkboxes.
>
> Thanks in advance for your helpful advices.
>
> Regards,
>
> Sascha