全国省市无刷新二级联菜单 求修改
全国省市无刷新二级联菜单 求修改,我是vs2008 c#
现在是刷新代码,要求修改后无刷新
前台代码:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>请选择</asp:ListItem>
<asp:ListItem>北京</asp:ListItem>
<asp:ListItem>上海</asp:ListItem>
<asp:ListItem>江苏</asp:ListItem>
<asp:ListItem>浙江</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server" Visible="False">
</asp:DropDownList></span>
后台代码:cs
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedIndex > 0) {
DropDownList2.Visible = true;
switch (DropDownList1.SelectedItem.Text)
{
case "北京":
DropDownList2.Items.Clear();
DropDownList2.Items.Add("朝阳区");
DropDownList2.Items.Add("海淀区");
DropDownList2.Items.Add("大兴区"); break;
case "上海":
DropDownList2.Items.Clear();
string a = "徐汇,静安,浦东,长宁,黄埔,闵行,虹口,杨浦,松江,奉贤,金山,普陀";
string[] mycity = a.Split(',');
for (int i = 0; i < mycity.Length; i++) {
DropDownList2.Items.Add(mycity[i] + "区");
}
break;
case "江苏":
DropDownList2.Items.Clear();
DropDownList2.Items.Add("南京市");
DropDownList2.Items.Add("无锡市");
DropDownList2.Items.Add("苏州市");
break;
case "浙江":
mybinding("宁波,杭州,绍兴,嘉兴,义乌", "市"); break;
}
}else{DropDownList2.Visible=false;}
}
------解决方案--------------------http://topic.csdn.net/u/20111016/17/7e574597-a2ba-45e1-ab14-77cc20adb8e9.html
------解决方案--------------------
直接下载一个JS代码,城市二级联动,不需要存放在数据库。