假设你有binding grid before and it has rows
。 在gridview的某行中找到ImageButton,而不是在gridview中查找。 if
条件似乎永远不会变成真,因为您正在比较ToUpper后面的字符串和非大写字符串,Change User1 to USER1
正如您使用的是ToUpper。通过循环
变化
Dim ImageButton1 As ImageButton = DirectCast(GridView1.FindControl("ImageButton1"), ImageButton)
If User.Identity.Name.Substring(InStr(User.Identity.Name, "\")).ToUpper = "User1" Then
ImageButton1.Visible = False
End If
要
Dim ImageButton1 As ImageButton = DirectCast(GridView1.Rows(0).FindControl("ImageButton1"), ImageButton)
If User.Identity.Name.Substring(InStr(User.Identity.Name, "\")).ToUpper = "USER1" Then
ImageButton1.Visible = False
End If
遍历整个网格
For Each row As GridViewRow In GridView1.Rows
Dim ImageButton1 As ImageButton = DirectCast(row.FindControl("ImageButton1"), ImageButton)
If User.Identity.Name.Substring(InStr(User.Identity.Name, "\")).ToUpper = "USER1" Then
ImageButton1.Visible = False
End If
Next
阿迪尔感谢您的快速反应,我想乌尔Ç它的工作,但只为第一行(索引= 0)。你能否在页面加载中包含绑定网格的代码? – user851971 2012-08-01 19:14:31
你需要使用循环遍历整个网格,检查我更新的答案。 – Adil 2012-08-01 22:37:45
chEERS,Adil ...像伏都教一样工作! – user851971 2012-08-02 13:53:13