方法定义:
1publicstaticvoidInitDropDownList(DropDownList ddl,boolisAddTopItem, DropDownList ddlSub,objectddlDataSource,stringddlTextField,stringddlValueField)2{3ddl.DataSource =ddlDataSource;4ddl.DataTextField =ddlTextField;5ddl.DataValueField =ddlValueField;6ddl.DataBind();7if(isAddTopItem)8ddl.Items.Insert(0,newListItem("--All--","0"));9if(ddlSub !=null)10ddlSub.Items.Insert(0,newListItem("--All--","0"));11}
使用方式:
1XXClass.InitDropDownList(ddlAvailableFieldEnter,false,null,newstring[]{"field1","field2","field3"},"","");