I've added a template column to a DataGrid that contains a checkbox control.
The default value for this checked. All items are checked on page load. I
add a column to my dataset that contains a default value as well. If a
record is unchecked in the grid, I need an event handler that can update the
dataset based on the ID or row. Right now I can add a OnCheckedChanged
handler on the HTML side of things and get that event to fire...which is
defined like this:
Public Sub cbSendTo_CheckChanged(ByVal sender As Object, ByVal e As
EventArgs)
' what goes here?
End Sub
But I can't figure out how to refer to the specific record in the DataSet
without doing some weird concatenation on ItemDataBound and then parsing the
control's name...which is way too hokey (I hope).
Dim chk As CheckBox = CType(sender, CheckBox)
Dim dgItem As DataGridItem = CType(chk.NamingContainer, DataGridItem)
If not chk.Checked Then
Dim dt As DataTable = Data_Table()
Dim dr As DataRow = dt.Rows.Find(DataGrid1.DataKeys(dgItem.ItemIndex))
If Not dr Is Nothing Then
'do the processing
End if
End If
You can see a demo on this link
http://www.societopia.net/samples/DataGrid_ChildControlsEvents.aspx

Signature
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
> I've added a template column to a DataGrid that contains a checkbox control.
> The default value for this checked. All items are checked on page load. I
[quoted text clipped - 12 lines]
> without doing some weird concatenation on ItemDataBound and then parsing the
> control's name...which is way too hokey (I hope).