Hey All
how can i handle acting with controls inside datalist
i would like to be able to make buttons and controls visable and invisable from the code behind but i havnt got a cue how to do this
Code examples would be nice
thanks in advance
Printable View
Hey All
how can i handle acting with controls inside datalist
i would like to be able to make buttons and controls visable and invisable from the code behind but i havnt got a cue how to do this
Code examples would be nice
thanks in advance
The datalist has a collection of DataListItems that contain each item within your datalist. You can access controls within each item by using the FindControl method and then assign the properties you need.
For example if I wanted to set a button control in the 3rd item of a datalist to be hidden I would do:
whereCode:Button btnExample = (Button) dlstExample.Items[2].FindControl("button");
btnExample.Visible = false;
HTHCode:<datalist id="dlstExample" runat="server">
<ItemTemplate>
<asp:Button id="button" runat="server" Text="Test" />
</ItemTemplate>
</datalist>
DJ