我有两个下拉列表,其中一个是“State”,另一个是“Cluster”。这两个下拉列表都是关系型的。例如,如果我在州选择喀拉拉邦,那么群集将填充其重要城市和dist。像Pathnamthitta,calicut,palakad等。
所以,我想要的是,我想在State和Cluster ddl中给出一个选项“Select All”。
我经历过:
How to select all records in a DropDownList
http://www.w3schools.com/aspnet/control_dropdownlist.asp
http://forums.asp.net/t/1221977.aspx?Adding+a+Select+all+option+to+a+drop+down+list
但他们都没有为我工作。我可以选择所有状态,但不能在其他ddl上填充聚类值。
这是我的“州”ddl代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataSet3TableAdapters.tbl_energy_reportTableAdapter state;
state = new DataSet3TableAdapters.tbl_energy_reportTableAdapter();
DataTable dt = new DataTable();
dt = state.GetDataByStateInnerJoin();
DropDownList1.DataSource = dt;
DropDownList1.DataTextField = "state1";
DropDownList1.DataValueField = "state1";
DropDownList1.DataBind();
DropDownList1.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select State--", "0"));
DropDownList2.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select Cluster--", "0"));
}
}
此代码适用于“群集”
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DataSet3TableAdapters.tbl_energy_reportTableAdapter state;
state = new DataSet3TableAdapters.tbl_energy_reportTableAdapter();
DataTable dt = new DataTable();
dt = state.GetDataByClusterInnerJoin(DropDownList1.SelectedValue);
DropDownList2.DataSource = dt;
DropDownList2.DataTextField = "cluster";
DropDownList2.DataValueField = "cluster";
DropDownList2.DataBind();
}
任何帮助将不胜感激....