accessing a button in datalist selected item mode

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top