【发布时间】:2012-06-22 21:26:34
【问题描述】:
我想在gridview 中找到控件(超链接)。根据控件的值,我想启用或禁用超链接。 我试过这样。但我总是变得空虚。
protected void gridResult_RowDataBound(object sender, GridViewRowEventArgs e) {
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink status = e.Row.FindControl("id") as HyperLink;
if ( status != null && status.Text == "AAAA" ) {
status.Enabled = false;
}
}
}
请帮忙。
【问题讨论】:
-
FindControl()不是递归的,所以如果超链接不是Row的直接子级,则不会找到它。您可能需要实现自己的递归版本才能获得所需的功能。有关更多信息,请参阅msdn.microsoft.com/en-us/library/486wc64h.aspx。 -
你好,你可以发送你的代码aspx
-
如 Aghilas 所述,如果以下答案未能解决您的问题,则需要您的 GridView ASPX 代码。
标签: c# asp.net gridview findcontrol templatefield