The following code is used:
1 <iswebgrid: webgridcolumn caption = "in "inputrequired = "true" name = "title" width = "70px"
2 columntype = "template" datamember = "isshow" edittype = "noedit">
3 <celltemplate>
4 <asp: checkbox runat = "server" id = "cbisshow" Checked = '<% # BIND ("isshow") %> 'enableviewstate = "true"
5 oncheckedchanged = "cbisshow_checkedchanged" enabled = "false"/>
6 </celltemplate>
7 </iswebgrid: webgridcolumn>
1 protected void cbIsShow_CheckedChanged(object sender,EventArgs e)
2 {
3 Response.Write("<script>alert(\"cbIsShow_CheckedChanged\");</script>");
4 }
When you click the checkbox in the template column, the cbisshow_checkedchanged method in the background is always not executed.
Google has many answers, such:
1. autopostback = "true" not written;
2. Set enableviewstate to false;
Not after the test.
After I remove the binding, the cbisshow_checkedchanged method runs normally.
My explanation is:
Oncheckedchanged meets the event trigger condition only after the checked attribute of the checkbox changes. The checked attribute of the checkbox in the template column is bound to the isshow field. without changing the data source, the checked attribute value of the checkbox does not change and does not meet the event trigger conditions. Therefore, it is normal to not run the event processing function.
The possible method is:
1. Add the client event onclicked for the checkbox and call the background method in JS.