这篇文章主要介绍了如何在RowCommand事件中获取索引值,需要的朋友可以参考下
在RowCommand事件中获取索引值
1.利用e.CommandSource
代码如下:
protected void lpg_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == “ItemCollect”)
{
GridViewRow gvr = (GridViewRow)(((LinkButton)(e.CommandSource)).Na来源gaodai#ma#com搞*!代#%^码网mingContainer);
LinkButton lk = lpgKnowledgeExchange.Rows[gvr.RowIndex].FindControl(“lbtnCollect”) as LinkButton;
}
}
2.如果是模板列中的button直接click事件
利用sender 取其parent 也可以实现
以上就是在RowCommand事件中获取索引值示例代码的详细内容,更多请关注gaodaima搞代码网其它相关文章!