DataList q for Plaus

bri189a

Senior Contributor
Joined
Sep 11, 2003
Messages
1,004
Location
VA
Or anyone else...

PlausiblyDamp let me know the wonders of the datalist control... much better than making dynamic tables... what I have is basically a page that is similiar to these... display items, and has buttons to edit or delete. The problem I'm having is that the edit and delete are only for administrators. How do I, via databinding, determine on a data list that because this guy isn't an administrator the buttons should not be visible... or I guess even loaded in this case? I'm learning a lot all at once and overwhelming myself... MSDE, ASP.NET, DataList control... if web form buttons have a visible property... could someone still back door it through 'View Source'... or does ASP.NET see that it isn't visible and doesn't even bother outputting it to HTML? Hope you follow... Thanks for the help...

Brian
 
You could so something like..

Code:
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then

   If Not blnAdministrator Then
      CType(e.Item.FindControl("btnDelete"), LinkButton).Visible = False
   End If

End If
 
Just a quick answer for now - you may want to investigate authentication within the .Net frame work. This will allow you to check if a user is in a particular role (group). The two main forms are Windows Authentication (useful if you have a windows domain) or Forms Authentication (if you need to create your own security model).
If you have a search on MSDN or www.gotdotnet.com you should find a fair few examples.
As to enabling or disabling these you may want to look at some of the events of the datalist - not sure which would be the most useful as my MSDN is playing up (doing a new install of VS at the moment).
 
Back
Top