Cascading Drop Down : Selecting Value from Code Behind

Posted on 2009-05-27
Medium Priority
Last Modified: 2012-05-07
I've been working with Cascading Drop Down's, which work great, but I would like to be able to select a value from the first drop down, have it populate and then select the other value from the second drop down. All from codebehind.

Anyone have any ideas on how to get this working?
Question by:directxBOB
  • 2
LVL 53

Expert Comment

ID: 24480933
C#.NET Articles -Cascading DropDownList Populate dropdown based on selection of other dropdown in ASP.NET
LVL 10

Expert Comment

ID: 24481073
I do it like this:
If Not Session("CountryID") Is Nothing Then mCountryDropDownList_CascadingDropDown.SelectedValue = Session("CountryID")
Here's my DDL
                 <asp:DropDownList ID="mCountryDropDownList" runat="server" style="width: 155px" CssClass="Form">
                <cc2:CascadingDropDown ID="mCountryDropDownList_CascadingDropDown" 
                    runat="server" Category="Country" LoadingText="Fetching list... please wait..." 
                    PromptText="- Country -" ServiceMethod="GetCountry" 
                    Enabled="True" TargetControlID="mCountryDropDownList">

Open in new window


Author Comment

ID: 24481536
Where are you putting :

If Not Session("CountryID") Is Nothing Then
mCountryDropDownList_CascadingDropDown.SelectedValue = Session("CountryID")

I have put this in my PageLoad but it's not working.
LVL 10

Accepted Solution

Espavo earned 2000 total points
ID: 24481732
I do it like this:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
    If Not Session("CountryID") Is Nothing Then mCountryDropDownList_CascadingDropDown.SelectedValue = Session("CountryID")
End If
End Sub

Open in new window


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
When you have multiple client accounts to manage, it often feels like there aren’t enough hours in the day. With too many applications to juggle, you can’t focus on your clients, much less your growing to-do list. But that doesn’t have to be the cas…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question