Click here to Skip to main content
15,913,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
Right now i am working on a project,i am facing a problem in cascading dropdown
I have three drop down and i had filled dropdown1 succesfully and then i had filled dropdown two on selected index of dpd1 and then drop three on selected index of dpd2.....now what happen when i am selecting index of dpd2 then it automaticali move back to is selcted index 1 on. so please help me where i am lacking in my code and it happen so...my code is like...


C#
//fill Asset site dropdown at form load
 ut.dropdownlistBind(DropDownList6, "SELECT [Site_ID],[Site_Name] FROM [FacilitiesManagementDB ].[dbo].[AssetSiteDetails] where [Company_ID]='" + Session["compid"].ToString().Trim() + "' order by [Site_Name] ", "Site_Name", "Site_ID");
 ddlAssetSite.Items.Insert(0, "----Select Site----");


//fill site block dropdown
protected void DropDownList6_SelectedIndexChanged(object sender, EventArgs e)
 {
 //fill Site Block
  ut.dropdownlistBind(DropDownList9, "SELECT distinct [Site_ID],[RoomLocation] FROM [FacilitiesManagementDB ].[dbo].[Room_mst1] where [Company_ID]='" + Session["compid"].ToString().Trim() + "' and Site_ID='" + DropDownList6.SelectedValue.ToString() + "' order by [RoomLocation] ", "RoomLocation", "Site_ID");
DropDownList9.Items.Insert(0, "----Select Block----");     
      }


  //fll site-block-room dropdown
 protected void DropDownList7_SelectedIndexChanged(object sender, EventArgs e)
 {
  //fill Site-Blocks-Rooms
  ut.dropdownlistBind(DropDownList8, "SELECT  [Site_ID],[RoomNo],[RoomLocation] FROM [FacilitiesManagementDB ].[dbo].[Room_mst1] where [Company_ID]='" + Session["compid"].ToString().Trim() + "' and Site_ID='" + DropDownList6.SelectedValue.ToString() + "' and RoomLocation='" + DropDownList7.SelectedItem.ToString() + "' order by [RoomNo] ", "RoomNo", "RoomLocation");
  DropDownList8.Items.Insert(0, "----Select Room----");
      }

i am also using Ajax tool kit script manager is there any problem due to that..


Thanx in advance...
Posted
Updated 25-Sep-12 0:45am
v3
Comments
vaibhav mahajan 25-Sep-12 6:47am    
pls debug ur code...r u filling ur drop down on page load?
karansaxena08 25-Sep-12 7:05am    
yes vaibhav i have fill dropdown on page load as well as i also debuged...but problem is still same..
vaibhav mahajan 25-Sep-12 7:15am    
fill the first drop down in !ispostback..then 2 nd on the selected index change of 1 st....n similarly for 3rd..
hope this will solve
[no name] 25-Sep-12 7:09am    
ispostback or !ispostback..?
karansaxena08 25-Sep-12 7:38am    
still not working..

1 solution

Your code to populate dropdown should be inside IsPostback condition as follows:

Page_Load()
{
if(!Page.IsPostback)
{
FillDropdown()//Populate dropdown here
}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900