为什么始终只能选第一条的
BLL.cities bc = new BLL.cities();BLL.provinces bp = new BLL.provinces();
protected void Page_Load(object sender, EventArgs e)
{
Dropsheng.DataSource = bp.GetModelList("");//读取省份全部记录绑定到下拉列表框
Dropsheng.DataTextField = "province";
Dropsheng.DataValueField = "provinceid";
Dropsheng.DataBind();
string s = Dropsheng.SelectedValue;
Dropshi.DataSource = bc.GetModelList(" provinceid=" + s);//读取城市全部记录绑定到下拉列表框
Dropshi.DataTextField = "city";
Dropshi.DataValueField = "cityid";
Dropshi.DataBind();
}
protected void Dropsheng_SelectedIndexChanged(object sender, EventArgs e)
{
string s = Dropsheng.SelectedValue;
Dropshi.DataSource = bc.GetModelList(" provinceid="+s);//读取全部记录绑定到下拉列表框
Dropshi.DataTextField = "city";
Dropshi.DataValueField = "cityid";
Dropshi.DataBind();
}
}
} --------------------编程问答-------------------- 服务端组件引起页面刷新,每次都会再次执行Page_Load中的数据绑定 --------------------编程问答-------------------- 把你的BLL.cities 中的确GetModelList(string ...);这个方法帖出来,有问题的地方应是这个方法内 --------------------编程问答-------------------- 哦! 解决了 谢啦! --------------------编程问答-------------------- 我在首次加载前面加了个ispostback 加载回发! 就好了 ! --------------------编程问答-------------------- 那还结贴吗 --------------------编程问答-------------------- protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
Dropsheng.DataSource = bp.GetModelList("");//读取省份全部记录绑定到下拉列表框
Dropsheng.DataTextField = "province";
Dropsheng.DataValueField = "provinceid";
Dropsheng.DataBind();
string s = Dropsheng.SelectedValue;
Dropshi.DataSource = bc.GetModelList(" provinceid=" + s);//读取城市全部记录绑定到下拉列表框
Dropshi.DataTextField = "city";
Dropshi.DataValueField = "cityid";
Dropshi.DataBind();
}
}
补充:.NET技术 , .NET Framework