c#中怎么实现两个下拉列表的联级操作
3个回答
2013-10-25
展开全部
后面的下拉列表根据前面下拉列表选中的元素进行检索和填充
2013-10-25
展开全部
在第一个的 下拉列表控件的 SeletedIndexChange 事件里面 写第二个下拉列表控件的代码
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-10-25
展开全部
/// <summary>
/// 加载省信息
/// </summary>
private void JzProvince()
{
this.ddlprovince.DataSource = BLL.NewInfo.TerminalOperator.TheInstance.GetProvinceInfo();
this.ddlprovince.DataTextField = "ProvinceName";
this.ddlprovince.DataValueField = "ProvinceID";
this.ddlprovince.DataBind();
} /// <summary>
/// 根据省初始化市
/// </summary>
private void InitCityByProvince()
{
ddlcity.Items.Clear();
String pid = ddlprovince.SelectedValue;
DataSet ds = BLL.NewInfo.TerminalOperator.TheInstance.GetProvinceInfoByCityID(Int32.Parse(pid));
this.ddlcity.DataSource = ds;
this.ddlcity.DataTextField = "CityName";
this.ddlcity.DataValueField = "CityID";
this.ddlcity.DataBind();
}
/// <summary>
/// 当省的信息改变时,加载其下面的市
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlprovince_SelectedIndexChanged(object sender, EventArgs e)
{
InitCityByProvince();
}
/// 加载省信息
/// </summary>
private void JzProvince()
{
this.ddlprovince.DataSource = BLL.NewInfo.TerminalOperator.TheInstance.GetProvinceInfo();
this.ddlprovince.DataTextField = "ProvinceName";
this.ddlprovince.DataValueField = "ProvinceID";
this.ddlprovince.DataBind();
} /// <summary>
/// 根据省初始化市
/// </summary>
private void InitCityByProvince()
{
ddlcity.Items.Clear();
String pid = ddlprovince.SelectedValue;
DataSet ds = BLL.NewInfo.TerminalOperator.TheInstance.GetProvinceInfoByCityID(Int32.Parse(pid));
this.ddlcity.DataSource = ds;
this.ddlcity.DataTextField = "CityName";
this.ddlcity.DataValueField = "CityID";
this.ddlcity.DataBind();
}
/// <summary>
/// 当省的信息改变时,加载其下面的市
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlprovince_SelectedIndexChanged(object sender, EventArgs e)
{
InitCityByProvince();
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询