S
Stu Lock
Hi,
I have a data grid with a checkbox column in it bound to database.
(IsItNumeric return either True/False).
<asp:TemplateColumn HeaderText="In List">
<ItemTemplate>
<asp:CheckBox id="InList" runat="server"
OnCheckedChanged="PersistToDB" Checked='<%#
IsItNumeric(DataBinder.Eval(Container, "DataItem.InList")) %>'
AutoPostBack="True">
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
This works fine. However, when a user changes the state of a particular
checkbox I handle the postback event 'PersistToDB'. I can get the checked
state of the checkbox that has just been chaged, but I cannot get the
'DataKey' of the row. I have been trying:
iMyVal = dgResult.DataKeys.Item(CType(sender, DataGridItem).ItemIndex)
I get the error 'Specified cast not allowed etc...'. Is there any way to get
the DataKey of the item that has changed (rather than looping and checking
the state of every single checkbox in the grid) ?
Thanks in advance,
Stu
I have a data grid with a checkbox column in it bound to database.
(IsItNumeric return either True/False).
<asp:TemplateColumn HeaderText="In List">
<ItemTemplate>
<asp:CheckBox id="InList" runat="server"
OnCheckedChanged="PersistToDB" Checked='<%#
IsItNumeric(DataBinder.Eval(Container, "DataItem.InList")) %>'
AutoPostBack="True">
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
This works fine. However, when a user changes the state of a particular
checkbox I handle the postback event 'PersistToDB'. I can get the checked
state of the checkbox that has just been chaged, but I cannot get the
'DataKey' of the row. I have been trying:
iMyVal = dgResult.DataKeys.Item(CType(sender, DataGridItem).ItemIndex)
I get the error 'Specified cast not allowed etc...'. Is there any way to get
the DataKey of the item that has changed (rather than looping and checking
the state of every single checkbox in the grid) ?
Thanks in advance,
Stu