在RowCommand事件中获取索引值示例代码

Katherine ·
更新时间:2024-09-21
· 580 次阅读

在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 也可以实现 您可能感兴趣的文章:用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对象讲解



示例 索引

需要 登录 后方可回复, 如果你还没有账号请 注册新账号