【发布时间】:2012-05-29 13:30:03
【问题描述】:
我在GridView中使用EditButton的OnClick事件
protected void editclick(object sender, EventArgs e)
{
try
{
Button EditButton = (Button)gvUserMaster.FindControl("edit_btn");
tblAddEdit.Visible = true;
}
catch(Exception ex)
{
}
}
但我得到了例外:
找到了具有相同 ID 'lblUserName' 的多个控件。 FindControl 要求控件具有唯一的 ID。
我尝试使用 foreach 循环,但也没有用。
【问题讨论】:
-
您能出示您的 ASPX 代码吗?错误消息表明一些
lblUserName。 -
好的,lblUsername 中有冗余,我解决了这个问题,但是你能不能得到编辑按钮的行 ID。