Q:

trigger button inside a repeater control

I have a button inside a repeater control and I would like to disable it. I tried something like this...
if (Session["USER_ID"] == null)
{
   //disable download button and     
}
else
{
   //enable download button
}

This is the button I want to enable and disable btnTEST
<asp:Repeater ID="Repeater1" runat="server" 
     OnItemCommand="Repeater1_ItemCommand">
   <ItemTemplate>            
         <asp:Image ID="image" ImageUrl='<%# Eval("image_src")%>' runat="server"  />                           
         <asp:Button ID="btnTEST" runat="server" Text="Click Me!" CommandName="testme" Enabled="False" />                          
   </ItemTemplate>
</asp:Repeater>

I am unable to use this:
btnTest.Enabled = True;

It doesn't work for some reason.

A:

Since the button is inside the Repeater-control it will be dynamically generated as many times as there are items in the datasource databound. So you have to enable/disable the button on the repeater ItemDataBound-event as so:
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        Button btn = (Button)e.Item.FindControl("btnTEST");

        if (Session["USER_ID"] != null)
        {
            btn.Enabled = true;
        }
    }

}

Ps. No need to disable since the button is disabled by default.

