高分求 dropdownlist的二级联动方法,关联的数据是从数据库中实时读取的
发布网友
发布时间:2022-04-27 12:18
我来回答
共3个回答
热心网友
时间:2022-04-27 13:48
托两个dropdownlist DropDownList1和DropDownList2
DropDownList1的AutoPostBack设为True,在后台写DropDownList1的
SelectedIndexChanged事件,再在SelectedIndexChanged事件里绑定
DropDownList2
前台
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
后台
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
//先获取dropdownlist1的selectedvalue
//绑定dropdownlist2
}追问谢谢,本人是菜鸟,阅读您写的,知道了大概的思路,请将//先获取dropdownlist1的selectedvalue
和//绑定dropdownlist2的代码大概写一下。。(dropdownlist1、dropdownlist2)里面的数据是通过条件查询从数据库中读出来的。
热心网友
时间:2022-04-27 15:06
DataTable dt = SysDataDictReader.GetComplexDataTypeByTypeCode("CIT_HR_RecruitStaff_DeptFacultyCfg", false);
DataView dv = dt.DefaultView;
dv.RowFilter = "PARENT_ORG='" + drpApplyDept.SelectedValue + "'";
hdfApplyDept.Value = drpApplyDept.SelectedItem.Text.ToString();
hdfApplyDeptID.Value = drpApplyDept.SelectedValue;
DataTable dvtb = dv.ToTable();
DataRow dr = dvtb.NewRow();
dr["ORG_NAME"] = "--请选择--";
dr["ORG_NO"] = "";
dvtb.Rows.InsertAt(dr, 0);
drpApplyOffice.DataTextField = "ORG_NAME";
drpApplyOffice.DataValueField = "ORG_NO";
drpApplyOffice.DataSource = dvtb;
drpApplyOffice.DataBind();
热心网友
时间:2022-04-27 16:40
用jquery吧