N
news.microsoft.com
I have a datagrid with a checkbox column. The column is bound to adatabase,
and I have no problem capturing a click event on the checkbox using the
OnCheckChanged event handler.
Here is a sample of the html used to build the column:
<asp:TemplateColumn HeaderText="Crew Chief?">
<HeaderStyle HorizontalAlign="Center" Width="40px"
VerticalAlign="Middle"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:checkbox id=chkChief runat="server"
cssclass="FormFieldText2"
OnCheckedChanged="cbChief_Clicked"
COMMANDARGUMENT='<%#Container.DataItem("SAN") %>'
AutoPostBack=True Checked='<%#
bSetCheckValue(Container.DataItem("IsChief"))%>'>
</asp:checkbox>
</ItemTemplate>
</asp:TemplateColumn>
The event handler function fires and I get a reference to the checkbox
object that was clicked.
The problem is that I am trying to get a reference to the row that the
checkbox was clicked in to retrieve the datakey value. I know I could loop
through the entire dataitem list and find the match, but what I was trying
to do was pass the datakey value for the row as a command arguement, so that
I can use the datakey value directly in the event handler.
Has anyone been able to make this work?
Thanks,
Marc.
and I have no problem capturing a click event on the checkbox using the
OnCheckChanged event handler.
Here is a sample of the html used to build the column:
<asp:TemplateColumn HeaderText="Crew Chief?">
<HeaderStyle HorizontalAlign="Center" Width="40px"
VerticalAlign="Middle"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:checkbox id=chkChief runat="server"
cssclass="FormFieldText2"
OnCheckedChanged="cbChief_Clicked"
COMMANDARGUMENT='<%#Container.DataItem("SAN") %>'
AutoPostBack=True Checked='<%#
bSetCheckValue(Container.DataItem("IsChief"))%>'>
</asp:checkbox>
</ItemTemplate>
</asp:TemplateColumn>
The event handler function fires and I get a reference to the checkbox
object that was clicked.
The problem is that I am trying to get a reference to the row that the
checkbox was clicked in to retrieve the datakey value. I know I could loop
through the entire dataitem list and find the match, but what I was trying
to do was pass the datakey value for the row as a command arguement, so that
I can use the datakey value directly in the event handler.
Has anyone been able to make this work?
Thanks,
Marc.