Do something absolutely is critical here to know whether it is horrible or not.
The following sample indicates what you saw is not horrible:
See, I have two controls: Label0 and TextBox1. I can assign values to them:
for (int i = 0; i < 2; i++)
{
if (i == 0)
{
Label lable = (Label)this.FindControl("Label" + i.ToString());
if (lable != null)
lable.Text = "Test Label " + i.ToString();
}
if (i == 1)
{
TextBox txt = (TextBox)this.FindControl("TextBox" + i.ToString());
if (txt != null)
txt.Text = "Test TextBox " + i.ToString();
}
}
See it? It is not a usual way, but, not as horrible as you saw.
modified on Monday, March 2, 2009 4:04 PM