B
buran
Dear ASP.NET Programmers,
I have a datalist, which displays employee information. In selected item
mode, the datalist displays detailed information and a button to switch to
edit mode. What I want to accomplish is to disable the button according to
the user (I use forms authentication). I am using the following code, but
getting "Object reference not set to an instance of an object" error:
Sub ItemSelected(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataListCommandEventArgs)
If e.CommandName = "Selected" Then
If Page.User.Identity.Name = "employee" Then
Dim myButton As Button
myButton = CType(e.Item.FindControl("btnGuncelle"), Button)
myButton.Visible = False
End If
dliPersonel.SelectedIndex = e.Item.ItemIndex
' then bind data...
End If
End Sub
Can anyone help me? Thanks in advance,
Buran
I have a datalist, which displays employee information. In selected item
mode, the datalist displays detailed information and a button to switch to
edit mode. What I want to accomplish is to disable the button according to
the user (I use forms authentication). I am using the following code, but
getting "Object reference not set to an instance of an object" error:
Sub ItemSelected(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataListCommandEventArgs)
If e.CommandName = "Selected" Then
If Page.User.Identity.Name = "employee" Then
Dim myButton As Button
myButton = CType(e.Item.FindControl("btnGuncelle"), Button)
myButton.Visible = False
End If
dliPersonel.SelectedIndex = e.Item.ItemIndex
' then bind data...
End If
End Sub
Can anyone help me? Thanks in advance,
Buran