Repeater事件OnItemCommand取得行内控件的方法
更新时间:2014年01月15日 15:24:58 作者:
这篇文章主要介绍了Repeater事件OnItemCommand取得行内控件的方法,有需要的朋友可以参考一下
记录一下,主要是这句:
TextBox txtNum = e.Item.FindControl("txtNum") as TextBox;
Repeater真是太强了,太灵活。除了Repeater别的都不用。
复制代码 代码如下:
<table>
<asp:Repeater ID="rptList" runat="server"OnItemCommand="rptList_ItemCommand">
<ItemTemplate>
<tr>
<td><asp:TextBox ID="txtNum" runat="server" Text='<%#Eval("ProNum")%>'></asp:TextBox></td>
<td><asp:Button ID="btnUpdate" runat="server" Text="更新"CommandName="update" CommandArgument='<%#Eval("PID") %>' /></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
复制代码 代码如下:
protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
{
switch (e.CommandName)
{
case "update":
string arg = e.CommandArgument.ToString();//取得参数
//找到激发事件的行内控件,这个很有用,能将更多需要的参数值传递过来。
TextBox txtNum = e.Item.FindControl("txtNum") as TextBox;
//下面执行业务逻辑
string jsStr = "<script>alert('删除成功!" + txtNum.Text + "')</script>";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", jsStr,false);
break;
}
Bind();
}
您可能感兴趣的文章:
- Repeater控件与PagedDataSource结合实现分页功能
- Repeater控件实现编辑、更新、删除等操作示例代码
- Repeater怎么实现多行间隔显示分隔符
- Repeater中嵌套Repeater的示例介绍
- repeater做删除前弹窗询问实例
- 给Repeater控件里添加序号的5种才常见方法介绍
- asp.net Repeater 数据绑定的具体实现(图文详解)
- Repeater控件绑定的三种方式
- ASP.NET笔记之 Repeater的使用
- asp.net Repeater分页实例(PageDataSource的使用)
- Repeater里switch的使用方法
- Repeater中添加按钮实现点击按钮获取某一行数据的方法
相关文章
asp.net文件上传解决方案(图片上传、单文件上传、多文件上传、检查文件类型)
这篇文章主要介绍了asp.net文件上传解决方案,包括:图片上传、单文件上传、多文件上传、检查文件类型等案例,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2015-09-09
Community Server专题一:概述Community Server
Community Server专题一:概述Community Server...2007-03-03
ASP.NET MVC 4使用PagedList.Mvc分页的实现代码
本篇文章主要介绍了ASP.NET MVC 4使用PagedList.Mvc分页的实现代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2017-07-07
实现DataGridView控件中CheckBox列的使用实例
最近做WindowsForms程序,使用DataGridView控件时,加了一列做选择用,发现CheckBox不能选中。搜索后,要实现DataGridView的CellContentClick事件,将代码贴一下2014-01-01
asp.net(文章截取前几行作为列表摘要)无损返回HTML代码
asp.net(文章截取前几行作为列表摘要)无损返回HTML代码,需要的朋友可以参考下2012-12-12


最新评论