I want to invisible a imgbutton in repeater when username not admin.So here my code
Check username function :
Protected Sub CheckUS(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
Dim Check As String = Session("UserName").ToString
Dim Img As ImageButton = New ImageButton
Img = DirectCast(e.Item.FindControl("DltImg"), ImageButton)
If Check = "admin" Then
Imgl.Visible = True
Else
Img.Visible = False
End If
End Sub
and I call function in :
<asp:Repeater ID=Rpt1 runat=server OnItemDataBound="CheckUS">
then it go this error :
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 69: End If
Line 70: Catch ex As Exception
Line 71: Throw ex
Line 72: Finally
Line 73: End Try
Error in load data and bind to repeater.
So I need some advices.Thank 4 ur read.