用循环如何提取多个控件的内容
protected System.Web.UI.WebControls.DropDownList DDL1;
protected System.Web.UI.WebControls.DropDownList DDL2;
protected System.Web.UI.WebControls.DropDownList DDL3;
protected System.Web.UI.WebControls.DropDownList DDL4;
protected System.Web.UI.WebControls.DropDownList DDL5;
protected System.Web.UI.WebControls.DropDownList DDL6;
protected System.Web.UI.WebControls.DropDownList DDL7;
protected System.Web.UI.WebControls.DropDownList DDL8;
protected System.Web.UI.WebControls.DropDownList DDL9;
protected System.Web.UI.WebControls.DropDownList DDLcomm1;
protected System.Web.UI.WebControls.DropDownList DDLcomm2;
protected System.Web.UI.WebControls.DropDownList DDLcomm3;
protected System.Web.UI.WebControls.DropDownList DDLcomm4;
protected System.Web.UI.WebControls.DropDownList DDLcomm5;
protected System.Web.UI.WebControls.DropDownList DDLcomm6;
protected System.Web.UI.WebControls.DropDownList DDLcomm7;
protected System.Web.UI.WebControls.DropDownList DDLcomm8;
protected System.Web.UI.WebControls.DropDownList DDLcomm9;
提取DropDownList里的内容
for (i=1;i <=9;i++)
{
s[i] = this.DDL+i.SelectedValue;
t[i] = this.DDcommL+i.SelectedValue;
}
该怎么取值,谢谢!
------解决方案--------------------for (i=1;i <=9;i++)
{
s[i] = ((DropDownList)this.FindControl( "DDL " + i.ToString())).SelectedValue;
t[i] = ((DropDownList)this.FindControl( "DDLcomm " + i.ToString())).SelectedValue;
}