在RowCommand事件中获取索引值示例代码
更新时间:2014年06月13日 15:26:40 投稿:whsnow
这篇文章主要介绍了如何在RowCommand事件中获取索引值,需要的朋友可以参考下
在RowCommand事件中获取索引值
1.利用e.CommandSource
protected void lpg_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ItemCollect")
{
GridViewRow gvr = (GridViewRow)(((LinkButton)(e.CommandSource)).NamingContainer);
LinkButton lk = lpgKnowledgeExchange.Rows[gvr.RowIndex].FindControl("lbtnCollect") as LinkButton;
}
}
2.如果是模板列中的button直接click事件
利用sender 取其parent 也可以实现
1.利用e.CommandSource
复制代码 代码如下:
protected void lpg_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ItemCollect")
{
GridViewRow gvr = (GridViewRow)(((LinkButton)(e.CommandSource)).NamingContainer);
LinkButton lk = lpgKnowledgeExchange.Rows[gvr.RowIndex].FindControl("lbtnCollect") as LinkButton;
}
}
2.如果是模板列中的button直接click事件
利用sender 取其parent 也可以实现
您可能感兴趣的文章:
- 用Command对象和RecordSet对象向数据库增加记录哪一个更好
- 使用Jmail及Winwebmail发信时系统记录中的错误:502 Error: command ...
- Delphi Command模式
- asp中command的在单条记录时,有些字段显示为空的问题
- javascript document.execCommand() 常用解析
- asp.net gridview的Rowcommand命令中获取行索引的方法总结
- php设计模式 Command(命令模式)
- php设计模式 Command(命令模式)
- 获取Repeter的Item和ItemIndex/CommandArgument实现思路与代码
- 解决VS2012 Express的There was a problem sending the command to the program问题
- bash scp command not found的解决方法
- GridView中动态设置CommandField是否可用或可见的小例子
- document.execCommand()的用法小结
- pip 错误unused-command-line-argument-hard-error-in-future解决办法
- ON_COMMAND_RANGE多个按钮响应一个函数的解决方法
- C#命令模式(Command Pattern)实例教程
- ASP基础知识Command对象讲解
相关文章
点击提交按钮后DropDownList的值变为默认值实现分析
在点击提交按钮后,页面上所有的绑定到数据库的控件值都恢复到默认值,下面与大家分享下DropDownList的值变为默认值2013-05-05
ASP.NET WebAPi(selfhost)实现文件同步或异步上传
这篇文章主要介绍了ASP.NET WebAPi(selfhost)实现文件同步或异步上传,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2016-11-11


最新评论