Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6727213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:01:23+00:00 2026-05-26T10:01:23+00:00

I have three CascadingDropDown s on a webpage that I use in many places

  • 0

I have three CascadingDropDowns on a webpage that I use in many places on my website. They’re loaded with Country, District and Area names from the database. I have successfully bound data with them and set them up to cascade. But I want to preselect three values in the three CascadingDropDowns when a user registers on my site.

After registration, I also need to see their data in the admin area, where I also need to preselect the three CascadingDropDowns with the values user selected. But I cannot figure out how to do this.

My Webservice code:

namespace ZetaSolutions.WebProjects.Web.Modules
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.Web.Script.Services.ScriptService()]
    public class PlaceSelection : System.Web.Services.WebService
    {
        [WebMethod]
        public CascadingDropDownNameValue[] BindCountryDropDown(string knownCategoryValues, string category)
        {
            SqlConnection conCountry = new SqlConnection(ZetaConfig.ConnectionString);
            conCountry.Open();

            SqlCommand cmdCountry = new SqlCommand("SELECT * FROM Country ORDER BY Name", conCountry);
            SqlDataAdapter daCountry = new SqlDataAdapter(cmdCountry);
            cmdCountry.ExecuteNonQuery();

            DataSet dsCountry = new DataSet();
            daCountry.Fill(dsCountry);
            conCountry.Close();

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

            foreach (DataRow dtRow in dsCountry.Tables[0].Rows)
            {
                string countryId = dtRow["CountryID"].ToString();
                string countryName = dtRow["Name"].ToString();

                countryDetails.Add(new CascadingDropDownNameValue(countryName, countryId));
            }

            return countryDetails.ToArray();
        }

        [WebMethod]
        public CascadingDropDownNameValue[] BindDistrictDropDown(string knownCategoryValues, string category)
        {
            int countryId;
            StringDictionary countryDetails = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
            countryId = Convert.ToInt32(countryDetails["Country"]);

            SqlConnection conDistrict = new SqlConnection(ZetaConfig.ConnectionString);
            conDistrict.Open();
            SqlCommand cmdDistrict = new SqlCommand("SELECT * FROM District WHERE CountryID=@CountryID ORDER BY Name", conDistrict);
            cmdDistrict.Parameters.AddWithValue("@CountryID", countryId);
            cmdDistrict.ExecuteNonQuery();

            SqlDataAdapter daDistrict = new SqlDataAdapter(cmdDistrict);
            DataSet dsDistrict = new DataSet();
            daDistrict.Fill(dsDistrict);
            conDistrict.Close();

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

            foreach (DataRow dtDistrictRow in dsDistrict.Tables[0].Rows)
            {
                string districtId = dtDistrictRow["DistrictID"].ToString();
                string districtName = dtDistrictRow["Name"].ToString();
                districtDetails.Add(new CascadingDropDownNameValue(districtName, districtId));
            }

            return districtDetails.ToArray();
        }

        [WebMethod]
        public CascadingDropDownNameValue[] BindAreaDropDown(string knownCategoryValues, string category)
        {
            int districtId;
            StringDictionary districtDetails = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
            districtId = Convert.ToInt32(districtDetails["District"]);

            SqlConnection conArea = new SqlConnection(ZetaConfig.ConnectionString);
            conArea.Open();
            SqlCommand cmdArea = new SqlCommand("SELECT * FROM Area WHERE DistrictID=@DistrictID ORDER BY Name", conArea);
            cmdArea.Parameters.AddWithValue("@DistrictID ", districtId);
            cmdArea.ExecuteNonQuery();

            SqlDataAdapter daArea = new SqlDataAdapter(cmdArea);
            DataSet dsArea = new DataSet();
            daArea.Fill(dsArea);
            conArea.Close();

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

            foreach (DataRow dtAreaRow in dsArea.Tables[0].Rows)
            {
                string areaId = dtAreaRow["AreaID"].ToString();
                string areaName = dtAreaRow["Name"].ToString();
                areaDetails.Add(new CascadingDropDownNameValue(areaName, areaId));
            }

            return areaDetails.ToArray();
        }
    }
}

My aspx code:

<table>
    <tr>
        <td>
            Country:
        </td>
        <td>
            <asp:DropDownList ID="ddlCountry" runat="server"></asp:DropDownList>
            <ajaxToolkit:CascadingDropDown ID="CountryCascading" runat="server" Category="Country" TargetControlID="ddlCountry" LoadingText="Loading Countries..." PromptText="Select Country" ServiceMethod="BindCountryDropDown" ServicePath="PlaceSelection.asmx">
            </ajaxToolkit:CascadingDropDown>
        </td>
    </tr>
    <tr>
        <td>
            District:
        </td>
        <td>
            <asp:DropDownList ID="ddlDistrict" runat="server"></asp:DropDownList>
            <ajaxToolkit:CascadingDropDown ID="DistrictCascading" runat="server" Category="District" TargetControlID="ddlDistrict" ParentControlID="ddlCountry" LoadingText="Loading Districts..." PromptText="Select District" ServiceMethod="BindDistrictDropDown" ServicePath="PlaceSelection.asmx">
            </ajaxToolkit:CascadingDropDown>
        </td>
    </tr>
    <tr>
        <td>
            Area:
        </td>
        <td>
            <asp:DropDownList ID="ddlArea" runat="server"></asp:DropDownList>
            <ajaxToolkit:CascadingDropDown ID="AreaCascading" runat="server" Category="Area" TargetControlID="ddlArea" ParentControlID="ddlDistrict" LoadingText="Loading Areas..." PromptText="select Areas" ServiceMethod="BindAreaDropDown" ServicePath="PlaceSelection.asmx">
            </ajaxToolkit:CascadingDropDown>
        </td>
    </tr>
</table> 

Can anyone please tell me how can I solve my problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:01:24+00:00Added an answer on May 26, 2026 at 10:01 am

    You will need to read the values in that you want to select from your ‘admin’ system and then use;

    DropDownList.SelectedValue = "value";
    

    on Page_Load with a postback check.

    See : SelectedValue Property

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three time series that I'm plotting, and I would like to use
Have three classes User, Group and Field. Many to many relationship on User /
Have three divs in a container that I want to float over a large
I have three unordered lists that have been created as Scriptaculous Sortables so that
I have three tables in the many-to-many format. I.e, table A, B, and AB
I have three activities in my application ... I use an intent to navigate
I have three domains (domain1.es, domain2.com, domain3.com). I need that: domain1.es OR www.domain1.es, show
Greetings, I have a problem to use selected value propriety of CascadingDropDown. I have
I have three models : class LevelTwoArea < ActiveRecord::Base has_many :places, dependent: :restrict end
I have three function calls that I think should be treated (about) the same,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.