无刷新二级联动dropdownlist

<asp:ScriptManager ID="ScriptManager2" runat="server" EnablePartialRendering="true">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
<asp:DropDownList ID="area" runat="server" Width="100px" DataSourceID="SqlDataSource1" DataTextField="proname" DataValueField="proid" AutoPostBack="true">

<asp:ListItem Selected="True" Value="1">选择区域</asp:ListItem>
<%--<asp:ListItem Value="2">11点-12点</asp:ListItem> --%>

</asp:DropDownList>


<asp:DropDownList ID="xiaoqu" runat="server" Width="100px" DataSourceID="SqlDataSource2" DataTextField="xiaoquname" DataValueField="lid" >

<asp:ListItem Selected="True" Value="1">请选择小区</asp:ListItem>
<%-- <asp:ListItem Value="2"></asp:ListItem> --%>

</asp:DropDownList> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (可选项:如果您不在此小区可选“其它”)</td>

</ContentTemplate></asp:UpdatePanel>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:guangdaConnectionString %>"
SelectCommand="SELECT * FROM [area] order by proid desc">

</asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:guangdaConnectionString %>"
SelectCommand="SELECT * FROM [xiaoqu] WHERE ([proid] = @Classid)">
<SelectParameters>
<asp:ControlParameter ControlID="area" Name="Classid" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>

转载于:https://www.cnblogs.com/skyboy110/p/7272534.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个是ajax 实现DropDownList刷新联动。里面有数据库结构和内容,表结构的是sql2000的, 关键代码: <SCRIPT language="javascript"> //城市------------------------------ function cityResult() { var city=document.getElementById("DropDownList1"); AjaxMethod.GetCityList(city.value,get_city_Result_CallBack); } function get_city_Result_CallBack(response) { if (response.value != null) { //debugger; document.all("DropDownList2").length=0;          var ds = response.value; if(ds != null && typeof(ds) == "object" && ds.Tables != null) { for(var i=0; i<ds.Tables[0].Rows.length; i++)      {      var name=ds.Tables[0].Rows[i].CityName;        var id=ds.Tables[0].Rows[i].ProvinceID;        document.all("DropDownList2").options.add(new Option(name,id));      } } } else { document.all("DropDownList2").length=0; } return } //市区---------------------------------------- function areaResult() { var area=document.getElementById("DropDownList2"); AjaxMethod.GetAreaList(area.value,get_area_Result_CallBack); } function get_area_Result_CallBack(response) { if (response.value != null) { document.all("DropDownList3").length=0;          var ds = response.value; if(ds != null && typeof(ds) == "object" && ds.Tables != null) { for(var i=0; i<ds.Tables[0].Rows.length; i++)      {        var name=ds.Tables[0].Rows[i].ProvinceName;        var id=ds.Tables[0].Rows[i].id;        document.all("DropDownList3").options.add(new Option(name,id));      } } } else { document.all("DropDownList3").length=0; } return } </SCRIPT>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值