前台:
<asp:DropDownList ID="Manager" AutoPostBack="true" runat="server" OnSelectedIndexChanged="DropDownList4_SelectedIndexChanged1"></asp:DropDownList>
后台:
void BindDropDownList4() { // DropDownList4.Items.Clear(); Manager.AppendDataBoundItems = true; Manager.Items.Add(new ListItem("经理", "-1")); //DropDownList4.Items.Add(new ListItem("请选择一个职位", "-1")); Manager.DataTextField = "Name"; Manager.DataValueField = "id"; string str = "select id,Name from Employee"; Manager.DataSource = DBHelper.GetTable(str); Manager.DataBind(); }
取值:string str=DropDownList4.SelectedValue;