Q:

List of controls in code behind

How can I add to a list<> some controls of my dashboard? I do something like List<String> NewList = new List<Strings>(){} but this throw me errors
I'm trying to add some linkButtons into the list.
I'm tying to do something like this but is wrong
protected void listLink(){
            List<LinkButton> linksList = new List<LinkButton>();
            listLink{

            }
        }

I want to use that list in other events
my linkbuttons are in visible = false;

A:

From what i understand you want to create a list of LinkButtons using Object Initialization way.
Below code snippet should help you.
Aspx code:
<form id="form1" runat="server">
   <asp:LinkButton ID="lnkBtn1" runat="server"></asp:LinkButton>
   <asp:LinkButton ID="lnkBtn2" runat="server"></asp:LinkButton>
</form>

Aspx.cs code:
List<LinkButton> lnkBtnCollection = null;

protected void Page_Init(object sender, EventArgs e)
    {
        //Object Initialization way
        lnkBtnCollection = new List<LinkButton>
        {
            lnkBtn1, lnkBtn2
        };

        //Second way  where items are added to the list after the list is created
        //lnkBtnCollection = new List<LinkButton>();
        //lnkBtnCollection.Add(lnkBtn1);
        //lnkBtnCollection.Add(lnkBtn2);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
       //Use LinkBtn Collection here 
       foreach (var lnkBtn in lnkBtnCollection)
       {

       }
    }

