在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 也可以实现
本文地址:https://www.stayed.cn/item/5399
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我