Hi,
Change the checkbox markup in the template column as:
<asp:CheckBox ID="cbDoMail" Visible="true" enabled="true"
Runat="server" Checked='<%# DataBinder.Eval(Container.DataItem, "DoMail")
%>' onClick='alert("Clicked");'></asp:CheckBox>
I have put alert() just for demo purpose. Of course, you can have your own
JS script here.
Another option is to handle the ItemDataBound event of the grid: Get the
reference to the checkbox control in the row being bound, and do
<chkbox>.Attributes.Add(..)
Eliyahu Goldin said:
This should be fine. Where is the datagrid mentioned in the subject?
Eliyahu
Sorry forgot to specifically mention the Datagrid...
Simply adding 'onClick="doJavascriptThing()"' ends up with '<span
onClick="doJavascriptThing()"><input type="checkbox"...' which is not very
useful.
Whenever I put 'cbDoMail.Attributes.Add("onClick", "doJavascriptThing()")'
in onLoad-event it throws an 'Object reference not set to an instance of an
object'.
Design-code:
<asp:TemplateColumn HeaderText="Mail">
<ItemTemplate>
<asp:CheckBox ID="cbDoMail" Visible="true" enabled="true"
Runat="server" Checked='<%# DataBinder.Eval(Container.DataItem, "DoMail")
%>'></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
Code-behind:
Protected WithEvents cbDoMail As System.Web.UI.WebControls.CheckBox
Private Sub Page_Load(......)
cbDoMail.Attributes.Add("onClick", "doJavascriptThing()")
....
Hope this this is more clear...