Q:

c# asp.net for append int value to the label id

I have the following label with ids:
<asp:Label ID="FromName0" runat="server"  Visible="true"></asp:Label>
<asp:Label ID="FromName1" runat="server"  Visible="true"></asp:Label>
<asp:Label ID="FromName2" runat="server"  Visible="true"></asp:Label>
<asp:Label ID="FromName3" runat="server"  Visible="true"></asp:Label>
<asp:Label ID="FromName4" runat="server"  Visible="true"></asp:Label>

I want to assign the values to the label ids using for loop.
I am using the following tags in c#:
for (int i = 0; i < count; i++)
{
var label = this.Controls.Find("FromName " + i, true) as Label;
label.Text = Session["DeliverAddress" + i].ToString();
}

But ‘Find’ shows error like below:
System.Web.UI.ControlCollections does not have the definition for ‘Find’. But I have already added ‘System.Web.UI’ dll file. Can anyone help me?
I am using dotnet framework 4.0.
Thanks in Advance.

A:

You can do this like this
  public  Control[] FlattenHierachy(Control root)
    {
        List<Control> list = new List<Control>();
        list.Add(root);
        if (root.HasControls())
        {
            foreach (Control control in root.Controls)
            {
                list.AddRange(FlattenHierachy(control));
            }
        }
        return list.ToArray();
    }

and 
protected void Page_Load(object sender, EventArgs e)
    {
        Control[] allControls = FlattenHierachy(Page);
        foreach (Control control in allControls)
        {
            Label lbl = control as Label;
            if (lbl != null && lbl.ID == "FromName0")
            {
                lbl.ID = "myid";//Do your like stuff
            }
        }
    }

