dropdownlist 怎么绑定数据库 完成联动 5

代码如下:cs:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;... 代码如下:
cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace CCCC
{
public partial class _1 : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{

}
}

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
{
int pname = int.Parse(DropDownList1.SelectedValue);
if (pname > 0)
{
string Sqlprovince = "select * from city where pname=" + pname + ""; //根据省份ID找城市

DropDownList2.DataTextField = "pname";
DropDownList2.DataValueField = "pno";
DropDownList2.DataBind();
DropDownList2.Items.Insert(0, new ListItem("--请选择城市--", "0"));
}
else
{
DropDownList2.Items.Clear();
DropDownList2.Items.Insert(0, new ListItem("--请选择城市--", "0"));
DropDownList3.Items.Clear();
DropDownList3.Items.Insert(0, new ListItem("--请选择县区--", "0"));

}
}
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
{

int cname = int .Parse(DropDownList2.SelectedValue);
if (cname > 0)
{
string SqlDataSource3 = "select * from xianqu where cname=" + cname + ""; //根据城市id找县区

DropDownList3.DataTextField = "cname";
DropDownList3.DataValueField = "cno";
DropDownList3.DataBind();
DropDownList3.Items.Insert(0, new ListItem("--请选择县区--", "0"));
}
else
{
DropDownList3.Items.Clear();
DropDownList3.Items.Insert(0, new ListItem("--请选择县区--", "0"));
}

}

}
protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
int pname = Convert.ToInt32(DropDownList1.SelectedValue);
int cname = Convert.ToInt32(DropDownList2.SelectedValue);
int xname = Convert.ToInt32(DropDownList3.SelectedValue);
}
}
}

分不多 谢谢!!!
运行时 没有变化啊 哎 我是新手
展开
 我来答
玩的太CT
2013-07-04 · 超过12用户采纳过TA的回答
知道答主
回答量:59
采纳率:0%
帮助的人:40.7万
展开全部
AutoPostBack="true"
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式