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

Reading number is top 10 articles
XML入门教程-XML DHTML 行为_[XML教程]
Asp.net总调用的3个事件_[Asp.Net教程]
C#中加强ListView控件的功能_[Asp.Net教程]
PHP环境下配置在线编辑器FCKeditor_[PHP教程]
delphi列表框组件(TListBox)使用实例
ASP.NET获取服务器IP与MAC地址的方法_[Asp.Net教程]
程序设计中的三层架构_[Asp.Net教程]
Sql,server,2005的XML最佳实施策略(3)_[SQL,Server教程]
Asp.net,MVC2.0初级教程-添加操作_[Asp.Net教程]
数据库的分页问题_[SQL Server教程]
Reading number is top 10 pictures
西班牙山村小景5
粉红蕾丝的美女
男人帮杂志里的惹火性感美女1
赵惟依写真1
Perfect small Laurie1
A beautiful girl to bud1
遇到插队的怎么办?
中国女孩大胆自拍,显露完美身材4
The hot big eye big breast beauty3
Sora aoi on twitter2
Download software ranking
Eclipse 4.2.2 For Win32
Tram sex maniac 2 (H) rar bag6
Call Of Duty2
Popkart Cracked versions Mobile phone games
Unix video tutorial3
双旗镇刀客A
Eclipse 4.2.2 For Win64
Sora aoi's film--cangkong_Blue.Sky
The Bermuda triangle3
VeryCD电驴(EasyMule) V1.1.9 Build09081
归海一刀 published in(发表于) 2014/1/30 1:20:50 Edit(编辑)
asp.net实现DropDownList、ListBox无刷新三级联动的方法_[Asp.Net教程]

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

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

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

前台代码:

asp.net实现DropDownList、ListBox无刷新三级联动的两种方法 <A href=""></A>


  



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的,你们转换下就可以了

来源:csdn







添加到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.