DataGrid控件中模板列的服务器控件,怎么添加事件代码
来源:互联网 发布:石家庄seo公司 编辑:程序博客网 时间:2024/05/20 19:45
<asp:TemplateColumn HeaderText="Enable">
<ItemTemplate>
<asp:CheckBox id="Check_Enable" runat="server"></asp:CheckBox>
<asp:Button ID="test" Runat="server" ></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
上面是datagrid 中的一段模板列代码, 我们现在有两种方法添加事件代码
1.
<asp:Button ID="test" Runat="server" CommandName="test"></asp:Button>
利用commandname
private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.CommandName=="test")
{
this.Label2.Text="test";
((System.Web.UI.WebControls.CheckBox)e.Item.FindControl("Check_Enable")).Checked=true;
}
}
2
<asp:Button ID="test" Runat="server" onclick="test_Click"></asp:Button>
利用button的onclick事件
protected void test_Click(object sender, System.EventArgs e)
{
this.Label2.Text="test";
}
- DataGrid控件中模板列的服务器控件,怎么添加事件代码
- 怎么触发DataGrid模板列中控件的事件
- 怎么触发DataGrid模板列中控件的事件?
- datagrid控件中添加checkbox控件列
- datagrid控件中添加checkbox控件列
- 在DataGrid等控件中添加自动编号的列
- DataGrid编辑状态添加DropDownList控件模板列、设置样式
- DataGrid的列中加入控件
- DataGrid控件中列的宽度()
- GridView模板列控件的事件设置
- flex中datagrid控件的itemclick事件
- DataGrid 列的控件输出
- datagrid控件中添加了checkbox控件的使用
- 向DataGrid控件中添加ComboBox控件
- DataGrid模板列中TextBox的焦点相应键盘事件
- DataGrid模板列中TextBox的焦点相应键盘事件
- DataGrid模板列中TextBox的焦点相应键盘事件
- DataGrid模板列中TextBox的焦点相应键盘事件
- FrontPage微软延长服务期至2014年1月
- 一组和软件有关的笑话
- Mysql开发中的外键与参照完整性
- 多个存储过程完整实例及调用方法
- 极限编程感悟
- DataGrid控件中模板列的服务器控件,怎么添加事件代码
- Alexa排名新高-升654位(手机网址之家,www.mobi123.cn)
- 字符,字节和编码
- Spring Hibernate在AOP方面的配置冲突解决之道
- 编写java最常见的21种错误
- 规律,自律,效率
- What's on CIO agendas in 2007: A McKinsey Survey
- JSF+MYFACES+HIBERNATE+SPRING+ACEGI+A4J
- 浏览器不能正常调用Media Player播放网上音乐的解决办法