programmatically access a control in ItemTemplate
How do I programmatically access a control inside the ItemTemplate of a DataList control? I want to set the .Visible property of a button depending on if the user is currently logged in or not.
Here's the ItemTemplate element of my DataList control. It contains a label and a button (btnEdit). The btnEdit is what I want to set visible/invisible (in the Page_Load event):
VB Code:
<ItemTemplate>
<asp:Label id="lblName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>'>
</asp:Label><BR>
<asp:Button id="btnEdit" Text="Edit" Runat="server" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "EmployeeID") %>' CommandName="Edit">
</asp:Button>
</ItemTemplate>
I just need the syntax to access the btnEdit control which is inside the ItemTemplate of a Datalist.
Thanks,
Greg