高分求 dropdownlist的二级联动方法,关联的数据是从数据库中实时读取的 20
3个回答
展开全部
托两个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的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)里面的数据是通过条件查询从数据库中读出来的。
展开全部
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();
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();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用jquery吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询