I used code below to hide template field Imagebutton on pageload but it DOES NOT work, Thanks in advance:
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
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
End Sub
Assuming you have
binding grid before and it has rows. Find the ImageButton in some row of grid instead of find within gridview. Theifcondition you have seems to never get true, as you are comparing string after ToUpper with a string that is not in upper case,Change User1 to USER1As you are using ToUpper.Change
To
Iterating whole grid by loop