我有一个列名Status。如果状态值=已批准,则使超链接域无法单击,名为编辑
ASPX.Code:
<asp:HyperLinkField DataNavigateUrlFields="Trasaction_Id" DataNavigateUrlFormatString="TransactionForm.aspx?id={0}"
HeaderText="Edit" Text="<img src='../images/edit-9.png' />" />
CodeBehind
protected void gdvReview_RowDataBound(object sender,GridViewRowEventArgs e)
{
var currentUserSession = (UserSession)Session["UserSession"];
if (currentUserSession == null) return;
var roleID = currentUserSession.RoleId;
if(roleID==3)
{
if (e.Row.Cells[10].Text.Trim()=="Approved")
{
var hyperlink = (HyperLink)e.Row.FindControl("Edit");
hyperlink.Attributes.Add("onclick","return false");
}
}
}
但它不起作用。
答案 0 :(得分:0)
只需禁用超链接。所以而不是
hyperlink.Attributes.Add("onclick","return false");
使用
hyperlink.Enabled = false;
,您的超链接变得无法点击