All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
收藏一段小的.net下的验证码片段_[Asp.Net教程]
ASP.NET2.0服务器控件之捕获回传事件_[Asp.Net教程]
C#中EventLog组件应用实例
PHP脚本的8个技巧(4)动态创建图象_[PHP教程]
C#网络应用编程基础练习题与答案(五)_.net资料_编程技术
ASP.NET从零起步设计网站全过程(1)_[Asp.Net教程]
Delphi类似Windows xp的程序界面
delphi组件vcl的方法有哪些
SQL子查询实例介绍_[SQL Server教程]
安装JDK,就可同时运行PHP和Java?_php资料_编程技术
Reading number is top 10 pictures
Startling Russian girl blind date scene1
清扫五脏垃圾,我有绝招
Street street fighting
西方气质的东方美女1
上传几张色图
2012 national geographic daily picture6
真正的国产-非模拍 贵在是真实2
中国的十元人民币的秘密
女人化妆前后的对比
人美胸美腿更美2
Download software ranking
I'm come from Beijing1
Boxer's Top ten classic battle6
ASP.NET.2.0.XML.高级编程(第3版)
网页特效实例大全
C++编程教程第三版
JSP+Ajax Web development typical examples
Boxer vs Yellow1
Unix video tutorial2
Ashlynn Video5
C语言教程TXT
归海一刀 published in(发表于) 2014/1/30 1:27:32 Edit(编辑)
DropDownList、ListBox实现无刷新三级联动的方法_[Asp.Net教程]

DropDownList、ListBox实现无刷新三级联动的方法_[Asp.Net教程]

DropDownList、ListBox实现无刷新三级联动的方法_[Asp.Net教程]
前台代码:




asp.net实现DropDownList、ListBox无刷新三级联动的两种方法


  



Height="432px" Width="168px">
Height="432px" Width="168px">
Height="432px" Width="168px">







后台代码:


DB cn = new DB();

Page_Load#region Page_Load
private void Page_Load(object sender, System.EventArgs e)
{
if (!this.IsPostBack)
{
this.down1_bind();
this.ListBox1.Attributes.Add("onchange", "XmlPost2(this);");
this.ListBox2.Attributes.Add("onchange", "XmlPost3(this);");
}
if (povinceid != "")
{
this.down2_bind(povinceid);
}
if (cityid != "")
{
this.down3_bind(cityid);
}
}

#endregion

property#region property
private string povinceid
{
get
{
if (ViewState["povinceid"] != null && ViewState["povinceid"].ToString() != "")
{
return ViewState["povinceid"].ToString();
}
else
{
if (Request["povinceid"] != null && Request["povinceid"].ToString() != "")
{
return Request["povinceid"];
}
else
{
return "";
}
}
}
set
{
ViewState["povinceid"] = value;
}
}
private string cityid
{
get
{
if (ViewState["cityid"] != null && ViewState["cityid"].ToString() != "")
{
return ViewState["cityid"].ToString();
}
else
{
if (Request["cityid"] != null && Request["cityid"].ToString() != "")
{
return Request["cityid"];
}
else
{
return "";
}
}
}
set
{
ViewState["povinceid"] = value;
}
}
#endregion

down2_bind#region down2_bind
private void down2_bind(string id)
{
string mystr = "";
string sql = "select cityID,city from city where father = ’" + id + "’";
DataTable dt = cn.ReturnTable2(sql);
if (dt.Rows.Count != 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
mystr += "," + dt.Rows[i][0].ToString() + "|" + dt.Rows[i][1].ToString();
}
mystr = mystr.Substring(1);
}
this.Response.Write(mystr);
this.Response.End();
}
#endregion

down3_bind#region down3_bind
private void down3_bind(string id)
{
string mystr = "";
string sql = "select areaID,area from area where father = ’" + id + "’";
DataTable dt = cn.ReturnTable2(sql);
if (dt.Rows.Count != 0)
{
for (int i = 0; i {
mystr += "," + dt.Rows[i][0].ToString() + "|" + dt.Rows[i][1].ToString();
}
mystr = mystr.Substring(1);
}
this.Response.Write(mystr);
this.Response.End();
}

#endregion

down1_bind#region down1_bind
private void down1_bind()
{
string sql = "select provinceID,province from povince";
DataTable dt = cn.ReturnTable2(sql);
this.ListBox1.DataSource = dt.DefaultView;
this.ListBox1.DataValueField = "provinceID";
this.ListBox1.DataTextField = "province";
this.ListBox1.DataBind();
}

#endregion




以上是实现listbox的方法,DropDownList的方法与它一样,只要替换下就可以了.

数据库这里上传不了,我把它放到我的资源里,你们要是想要的话,就到我的资源里去下载下来,或者你们自己建表看效果.地址是:http://download.csdn.net/user/ainir1314520;数据库是access的,你们转换下就可以了




添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.