There may be an easier way, but if you chose a numeric naming
convention for your fields, than you can loop through them.
e.g.
str1, str2 //for text box
ddl1, ddl2 //for drop down list
CODE...
Page pgPage = this.Page; //or pass the page into the procedure if you
are using a class.
int intControl = 1;
int intControls = 55 //If you have 55 controls on your page
while(intControl <= 55)
{
TextBox strTextBox = pgPage.FindControl("str" + intControl) as TextBox;
strTextBox.Text = "Test"; //Set the value to whatever you want it to be
intControl += 1; //Move to the next control
}
//Repeat for DropDownLists and other control types, e.g.
while(intControl < 55)
{
DropDownList strDropDownList = pgPage.FindControl("ddl" + intControl)
as DropDownList;
strDropDownList.SelectedValue = "Test"; //Set the value to whatever you
want it to be
intControl += 1; //Move to the next control
}
In my application I have a whole load a variables for controls, so I
store them in a database table along with the control ID and perform
the same loop, but through a recordset.
Hope this is useful.
Jared