I have two drop-down lists in which one is “Status” and the other is “Cluster”. Both of these drop-downs are relational. For example, if I select Kerala in State, Cluster will populate important cities and dist. like Pathnamthitta, calicut, palakad, etc.
So, I want, I want to give the option "Select All" in State and Cluster ddl.
I went through:
How to select all entries in 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
But none of them worked for me. I can be able to select everything in a state, but not get cluster values populated on another ddl.
This is my code for the "State" 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();
}
ddl:
SELECT DISTINCT tbl_site_details.state1
FROM tbl_site_details INNER JOIN
tbl_energy_report ON tbl_energy_report.Site_ID = tbl_site_details.site_id
ddl:
SELECT tbl_site_details.cluster
FROM tbl_site_details INNER JOIN
tbl_energy_report ON tbl_energy_report.Site_ID = tbl_site_details.site_id
WHERE (tbl_site_details.state1 = @state1)
user3985746