方法一(后台方法):
前台:
<SELECT id="ddl_PreExecuteDepartment" tabIndex="-1" name="ddl_PreExecuteDepartment" runat="server">
<OPTION selected></OPTION>
</SELECT>
后台:
1、protected System.Web.UI.HtmlControls.HtmlSelect ddl_PreDepartment;
2、private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
DataSet myds = D_Prescription.GetPreAndExecDepartment(txt_cantonCode_ch.Value);
ddl_PreDepartment.DataSource = myds;
ddl_PreDepartment.DataTextField = "DD_Name_Vc";
ddl_PreDepartment.DataValueField ="DD_Code_Vc";
ddl_PreDepartment.DataBind();
ddl_PreExecuteDepartment.DataSource = myds;
ddl_PreExecuteDepartment.DataTextField = "DD_Name_Vc";
ddl_PreExecuteDepartment.DataValueField ="DD_Code_Vc";
ddl_PreExecuteDepartment.DataBind();
}
方法二(js方法):
var sel = document.getElementById("department");
var option = new Option(text, val);
sel.options.add(option);
方法三(miniUI):
<input id="shi" name="shi" class="mini-combobox" allowinput="false" onvaluechanged="ChangeShi" style="width: 100px;" textfield="CantonName" valuefield="CantonCode" emptytext="请选择所属盟市..." url="../FeedbackManage/ashx/AllQuery.ashx?type=GetCantonList_shi" value="" allowinput="true" />
在url调用的后台方法中查询CantonName和CantonCode自动赋值