Cascading Dropdown List - Selecting a value in the dropdown list from a user selection


First post so hello and need some help with an issue I have been dealing with.  I have an intranet page I created in ASP.NET using C# .NET 3.5 with a few Ajax Extenders including 3 Cascading Dropdown Lists.

Now I have used the Cascading dropdown lists for my own purposes i.e they do not actually cascade their results to another dropdown list, the reason I did this was due to the having a User Control that contains an update panel and other bits i.e I didn't want the control/page posting page (something that happens when you click on a regular dropdown list).

Everything is working okay so far, I have a Web Service that takes in a context key, based on this context key then goes off to the data access layer and pulls back whatever results I asked it to, all fine so far.  The dropdown list populates with the relevant values and I am able to select a particluar item from the dropdown list without any postback issues etc, I am also able to grab the selected value when doing a postback or where I have some javascript/ajax function that is trying to workout if the user has selected something.

This particular user control also gets populated (has several fields) when a querystring is passed to the page it populates the fields during the page load (so my Page_Load method checks for this and goes off and grabs some values from a bunch of public properties to populate the user control controls).

The problem I am having is not being able to change the dropdown list that is wrapped in the extender, it's obviously grabbing the dropdown list values correctly from the web service however it completely ignores any value I try to set it to so always shows selectedindex 0 (in this case the dropdown list shows "Please Select an Item").  I've tried a few things but I just don't understand the cascading dropdown extender well enough to know whats going and how to fix this.

What I want to be able to do is to check the querystring, find a value so go off and grab the values and populate the various controls (I have a class that encapsulates the data, on a previous page the public properties of this class get populated savinging having to hit the database/dataset all over again and also allows me to keep the selected/searched record data static for that session).  During this process I want to be able to check what dropdown list value was set in the public property and then tell the dropdown list to show this value... while using the cascading dropdown extender.

If you understand the above I'll buy you a pint ;-)

Here is my web service code:

/// <summary>

/// Helper web service to populate webform Dropdown Lists

/// </summary>

[WebService(Namespace = "")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]


public class DropdownListBuilder : System.Web.Services.WebService


#region member variables

public static DataAccess dahelper = new DataAccess();

public static ArrayList listddldata;

List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();


constructorspublic DropdownListBuilder()


//Uncomment the following line if using designed components




[WebMethod]public CascadingDropDownNameValue[] GetDropDownListData(string category, string contextKey)


DataTable dtlist = new DataTable();

// check the contextKey being passed in and retrieve a list of the dropdown list values

switch (contextKey)


case "1": // TLD/Country List

dtlist = dahelper.GetTLDCountryList();

foreach (DataRow dr in dtlist.Rows)



new CascadingDropDownNameValue((string)dr["Cakes"], dr["ID"].ToString()));



case "2": // Decision

dtlist = dahelper.GetDecisionsList();

foreach (DataRow dr in dtlist.Rows)



new CascadingDropDownNameValue((string)dr["Biscuits"], dr["ID"].ToString()));


break;case "3":

dtlist = dahelper.GetReasonList();

foreach (DataRow dr in dtlist.Rows)



new CascadingDropDownNameValue((string)dr["Jaffarcakes"], dr["ID"].ToString()));




return values.ToArray();



One of the extender's as they appear on the aspx page source:

<cc1:CascadingDropDown ID="CascadingDropDown2" runat="server" TargetControlID="ddlDecisions"

Category="Cakes" PromptText="Select a Cake... or bake one dude!" ServicePath="~/DropdownListBuilder.asmx"

ServiceMethod="GetDropDownListData" ContextKey="2" LoadingText="[Loading Cakes..]">



If you need anymore info don't hesitate to ask, I am off to smoke a cig as this has been doing my head in all day.



4/9/2008 4:41:14 PM 17816 articles. 1 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 56


Similar Artilces:

How to combind two dropdown list values into one dropdown list?
Hi All, I refered some websites, they are combinding two dropdown list values into single, but i don't know .Net will support it or not? If any body knows it plz tell me how to achieve it?? EX: Go to and select Functional Area dropdown list there u can see main & sub category names in one dropdown list!!!   Thanks, Aswath.  hi just concatenate , or - for ex:Dropdownlist1.Datatextfield= maincategory & "," & Subcategory Regards,M.VenkatesanMy Blog : http://venkat-dotnetsamples.blogspot.comPlease remember to click “Mark as Answer” on the pos...

Populate a Dropdown List based on the value of another Dropdown List
 Hi ALL,    I have two Dropdown List.I need to Populate second Dropdown List based on the value of first Dropdown List.I am n't using Update Panel.Pls suggest me RegardsSri ASP.NET AJAX Cascading DropdownDarrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you!   just populate second dropdown in SelectedIndexChanged event of the first dropdown. Muhammad ShoaibSoftware Engineer,Lahore, (U/C)--------------------------------Mark it as ANSWER if it Helps U   Check out this link with co...

How to get value from first dropdown list to second dropdown list
Hi Does soneone know hot to get value from first dropdown list to second dropdown list or remove it from seond dropdown list? I have a web form page. On the page, there are two dropdown lists, one Add button, and one Remove button . First dropdown list has four list items. Second one does not have list item yet. When select a item from first dropdown list, then click "add" button. I want it to apear in the second dropdown list without reload the page. Or select item from second dropdown list, and click "Remove" button. it will remove from second list. Please help. &nb...

one dropdown list affecting another dropdown list
I am desgining a website using VB.NET wherein the data items of one dropdown list depends on the selection of a data item in the previous dropdown list something similar to selection of country USA from 1st dropdown list...triggers 2nd dropdown with list of states in USA How can this be accomplished.... Any help will be appreciated... Thanks & Best Regards... hi boy,first I suggest turn on auto postback on first dropdownlist. In select index changes(first dropdownlist) - select value on second dropdownlist My blog is here.Please remember to 'Mark as Answer' i...

BUG: Cant access the values of dropdowns of Cascade Dropdown list in Page_Load
HiBUG: We cant access selected values of drop downs in Page_Load. As we know control.Load event occured after Page.Load. And If you look into CascadingDropDownExtender.cs, you can see OnLoad method is used to assign the client state value to the item so that we can use its value.protected override void OnLoad(EventArgs e)        {            base.OnLoad(e);            foreach (CascadingDropDownProperties cascadingDropDownProperties in TargetProperti...

populate a dropdown list on the basis of other dropdown list
I need to populate a dropdown list on the basis of other dropdown list. Both dropdwon list are datasourced with SQL datasource. I tried the SQL datasource where query . but it will need a post back. I dont want my form to be postback. I guess this is what AJAX is for but i really dont know how to get this with AJAX in a simple and quick way..... or it is not simple and quick ????Mark as answer if anybody's post has helped you It can be simple and quick.  See this video: And also the tutorial on how to use the Cascading Dropdow...

Filter dropdown list from another dropdown list
Help Please!!! I am trying to filter the data in a dropdown list from information chosen in another dropdown list. 1st table has modification types, 2nd table has modifications. When the user chooses the modification type needed, then only those modifications should appear in the 2nd list. mydata7 = New SqlDataAdapter("Select * from ModificationList ", myconnection) ds7 = New DataSet mydata7.Fill(ds7, "table") Dim dr7 As DataRow ddlModification.Items.Add("Please select Modification ...") ...

Dropdown list bound to another dropdown list
I have two dropdown lists on my page. The first contains a list of names and the second contains a list of hardware devices. My problem is: When i choose a name from the first dropdown i need the second to become populated with their related devices. This works fine, however if i then change the name in the first dropdown list, it adds another set of devices to the devices dropdown list. The way i want it to work is to refresh the devices dropdown when the name is changed. So that only that persons related devices show up (in the second dropdown)  Any help would be much apprecia...

How to use values from two dropdown lists to get the value for a third dropdown?
I have three dropdown lists.  One for Office, one for Department, and a list of employees.   There is no relationship in the database between office and department.  The relationships are to the employees.  What I need to do is take the selected values from Office and Department, and run a query to get the list of employees who match both parameters (Office & Department).  Here's my code for the three dropdown lists.  How do I "connect" Office & Department to populate employees?  code from my page    for the ...

Can I populate a Dropdown list in a GridView from another Dropdown list
Hi there, I have a Gridview control that contains 2 DDLs. The first one is populated on page load (from a Generic list in the code behind) and is working with no problems. I want to populate the 2nd DDL by making a selection in the first DDL which in turn would call a DB method and cause a postback. I've tried using the "OnSelectedIndexChanged" method for the DDL and the "FindControl" method for the 2nd DDL, but the GridView can't find it on Postback and throws an error. I've also tried using the "onSelectedIndexChanged" method for the GridView bu...

Drop down list in Form view returns error when value in bound field (data binding
I get the following error when I click edit to edit the details in the web form:'ddlUserRestrictionType' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value  I would like it to accept any value which currently exists in the database. Is this easily achievable? With what you've posted, all I can tell is that you are trying to set the SelectedValue of a ddl to a value that does not exist in the list.  It would be helpful if you can post some code and the expected values of this control.~ Timwww.bucketo...

ajax + update panel + dropdown list + trigger = dropdown list flashing
Hi,I have a dropdown list inside an ajax update panel, have the trigger to refresh every 2 seconds, all works great except the dropdown list refreshes every 2 seconds and visually it doesn't look right (the whole drop down box flashes), how do i set it so the dropdown box doesn't flash every 2 seconds? TIA   does it have something to do with binding the control on the trigger? Hi Joey_Crack, Would you please post the simple sample which contains your issue?  So we can troubleshoot in your shoes.  I have made a simple sample based on your descri...

Problem with 2 dropdown lists (second dropdown list reset automatically)
My Question is pretty simple.I have two dropdown lists. Once I clicked on one then second one gets populated (through SelectedIndexChanged and with AutoPostBack = true) now I am selecting the value in the second dropdown list and then hitting submit button. I am now sending these values to another page. but hte value in second drop downlist is always selected the first value (though i have selected the item other than first one)I am loading first dropdownlist in page load and under (if (!IsPostBack){ } )This is very silly things happening any bdoy has any idea about this or faced the same pr...

Cascading DropDown Will not load first Dropdown List
All, For some reason my webservice is not being called, however on the first dropdownlist the prompttext is in the list but not selected as the first entry.  The second dropdownlist displays the prompttext and is disabled as it should be. Not sure what to do to get it to work. Secondly, can some one explain the purpose of the "Category" and how does it tie in to this whole thing?  Is the name choosen for the category important? I have attached my page and webservice can please look at it and tell me what am I doing wrong.   Thanks in advance for any assistance hughp &nb...

Populating dropdown list inside datagrid when an item in a dropdown list out side the datagrid changed
 Hi,I have a Dropdown list out side the Datagrid, which lists the Technology (for example). Now below this I have a datagrid which has one dropdown list which will populate the Subject (which is related to the Technology dropdown list). Help me to achive this.In short: when outside dropdown changes correspondingly the inside drop down list should be changed Thans in AdvanceRamesh  On the SelectedIndexChanged event of your outside DropDownList, re-bind your DataGrid. Then within the ItemDataBound event of the DataGrid, retrieve a reference to your inner DropDownList, and re-b...

Web resources about - Cascading Dropdown List - Selecting a value in the dropdown list from a user selection -

Cascading Style Sheets - Wikipedia, the free encyclopedia
Cascading Style Sheets ( CSS ) is a style sheet language used for describing the presentation semantics (the look and formatting) of a document ...

Ads API Profile: Alchemy’s Cascading Ad Creation, Analytics, and Auto-Optimization
Facebook’s performance advertising system provides buyers with a wealth of targeting options, but not the depth of control or analytics to effectively ...

Twitter blames global outage on 'cascading bug'
AFTER nearly a year without any significant periods of downtime, using Twitter was almost nothing like the early days of being on the service. ...

In defence of Gen Y, and cascading generations, by a boomer
Some accuse Generation Y of feeling entitled, overly precocious, demanding and rude but that doesn't necessarily reflect reality.

In defence of Gen Y, and cascading generations, by a boomer
Some accuse Generation Y of feeling entitled, overly precocious, demanding and rude but that doesn't necessarily reflect reality.

Cascading Style Sheets - 9to5Mac
Adobe announced updates on Thursday to many of its HTML5 design tools for Creative Cloud users. Among the updates, we get new features for Edge ...

West Texas Cascading Safety Failure
In the interests of Calamity Fairness, here’s a most depressing Bloomberg article : Texas Explosion Seen as Sign of Weak U.S. Oversight The ...

Watch this captivating video of 11,000 marbles cascading down a marble run
Everyone has a hobby. Some people like to play recreational sports, others prefer to go fishing, but did you know there are creative types out ...

Austria Announces Fence With Slovenia; Irony of German Whine; Cascading Fences; Mish Proposed Strategy ...
Two months ago, Austria's chancellor Werner Faymann criticized Hungary for building a fence along its border. Faymann proclaimed "To think that ...

Cascading Slopes is Jacob from The Drums' new band, NYC residency this month
Cascading Slopes at Cameo, 1/31/2013 (via @FreshBread) Cascading Slopes is a new project from Jacob Graham of The Drums. Unlike his other band, ...

Resources last updated: 12/24/2015 1:48:51 AM