Need to dynamically add or remove the EditButton on a Editable DataList in VB.NET

  • Thread starter Thread starter jack
  • Start date Start date
J

jack

Hello,

I have a editable DataList, and would like the Edit Button to be appear or
not appear dynamically based on the access the logged in person has.

I have tried to use the visible=false, with no luck.

Any help would be great an example in VB.NET would be the most helpful.

Thanks in advance for your time and help,

Jack
 
You can accomplish this in the itemcreated event of the DataList. Use a
template, so you can give your controls a recognizable ID. Here is an
example of how to find a particular control:

Dim itm As DataListItem = e.Item
Select Case itm.ItemType

Case ListItemType.EditItem
tb = DirectCast(itm.FindControl("txtStartDate"), TextBox)

Then, you can set the .visible property as needed.
 
Back
Top