|M| 在DataGrid中绑定了一个:CheckBox 如何设置他点击时的的后台事件命令
我将
-----------------------------------------
<asp:TemplateColumn HeaderText= "当前状态 ">
<ItemTemplate>
<asp:LinkButton ID= "btn_State " CommandName= "btn_State " CommandArgument= ' <%# Eval( "DetailID ") %> '
runat= "server " Text= ' <%# Convert.ToInt32(Eval( "State ")) == 0 ? "当前无效 " : "当前有效 "%> ' />
</ItemTemplate>
</asp:TemplateColumn>
-------------------------
改成
------------------------
<asp:TemplateColumn HeaderText= "当前状态 ">
<ItemTemplate>
<asp:CheckBox ID= "ck_State " AutoPostBack= "true " Checked= ' <%# Convert.ToInt32(Eval( "State ")) == 0 ? "false " : "true "%> ' runat= "server " />
</ItemTemplate>
</asp:TemplateColumn>
-----------------------------
请问我要怎么给ck_State添加像CommandName= "btn_State "这样的事件
好让我在后台编写代码
谢谢
------解决方案--------------------protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
}
毕竟是不同的控件 ,
------解决方案--------------------前台先注册 OnCheckedChanged= "ck_State_CheckedChanged "
后台写
protected void ck_State_CheckedChanged(object sender, EventArgs e)
{
}
------解决方案--------------------aspx:
<asp:CheckBox id=ck_Staterunat= "server " OnCheckedChanged= "AllDisply " Checked= ' <%# Convert.ToInt32(Eval( "State ")) == 0 ? "false " : "true "%> ' AutoPostBack= "True "> </asp:CheckBox>
cs:
protected void AllDisply( object sender, System.EventArgs e )
{......}
------解决方案-------------------- <asp:CheckBox ID= "ck_State " onclick= "javascript: this.nextSibling.click(); " Checked= 'false ' runat= "server " /> <asp:Button CommandName= "aaa " ID= "btn1 " runat= "server "/>
------解决方案-------------------- <asp:CheckBox ID= "ck_State " onclick= "javascript: this.nextSibling.click(); " Checked= 'false ' runat= "server " /> <asp:Button CommandName= "aaa " ID= "btn1 " style= "display:none " runat= "server "/>