Better way of definding label control at run time
-
Hi all , I am using C# , asp.net ,visual studio 2005. I am defining label control at runtime as Label item1 = new Label(); And assigning its id as Item1.ID = "item1"; But problem is that I have to define it for 250 label control. Actually I tried it to define through loop but its not working. Is better way of coding posiible or we have to define all 250 label control Please help Thanks imran khan
-
Hi all , I am using C# , asp.net ,visual studio 2005. I am defining label control at runtime as Label item1 = new Label(); And assigning its id as Item1.ID = "item1"; But problem is that I have to define it for 250 label control. Actually I tried it to define through loop but its not working. Is better way of coding posiible or we have to define all 250 label control Please help Thanks imran khan
But why you want to define 250 labels ? Can you tell the business requirement behind so that could help you more that just giving answer
Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
Hi all , I am using C# , asp.net ,visual studio 2005. I am defining label control at runtime as Label item1 = new Label(); And assigning its id as Item1.ID = "item1"; But problem is that I have to define it for 250 label control. Actually I tried it to define through loop but its not working. Is better way of coding posiible or we have to define all 250 label control Please help Thanks imran khan
This works fine for me:
for (int i = 0; i < 250; i++) { Label l = new Label(); l.ID = "label" + i.ToString(); l.Text = i.ToString(); this.Controls.Add(l); }
Can you share some code? What do you mean it is not working? What is it doing?
"Half this game is ninety percent mental." - Yogi Berra If you can read thank a teacher, if you can read in English, thank a Marine.