在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 也可以实现

以上就是在RowCommand事件中获取索引值示例代码。成功的路上,没有终点,但总有危险;没有满足,但总有不足;在成功的道路上,最基本的是:学习是出路更多关于在RowCommand事件中获取索引值示例代码请关注haodaima.com其它相关文章!