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 6810539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:13:04+00:00 2026-05-26T20:13:04+00:00

Greetings, I have a problem to use selected value propriety of CascadingDropDown. I have

  • 0

Greetings,
I have a problem to use selected value propriety of CascadingDropDown.

I have 3 asp dropdown controls with ajax CascadingDropDown for each one of them.

I have no problem to bind data to the 3 CascadingDropDown but my problem is to rebind CascadingDropDown.

simply what I want to do is to select a record from Gridview which has the selected values for the CascadingDropDown that I want to pass then rebind the CascadingDropDown with selected value.

I’m posting my code down which include:

1-ASP.NET code.

2-Code behind to handle selected record from grid view.

3- web servisice that handle binding data to the 3 CascadingDropDown.

please advice how to rebind data to CascadingDropDown with selected value.

by the way I used selected value proprety as showning in my code but it is not working and there is no error.

Thank you,

……………………
ASP.NET code
……………………

 <%@ Page Title="" Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="IMAM_APPLICATION.WebForm1" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="idcontact_info" DataSourceID="ObjectDataSource1" 
        onselectedindexchanged="GridView1_SelectedIndexChanged">
        <Columns>
            <asp:CommandField ShowSelectButton="True" />
            <asp:BoundField DataField="idcontact_info" HeaderText="idcontact_info" 
                InsertVisible="False" ReadOnly="True" SortExpression="idcontact_info" />
            <asp:BoundField DataField="Work_Field" HeaderText="Work_Field" 
                SortExpression="Work_Field" />
            <asp:BoundField DataField="Occupation" HeaderText="Occupation" 
                SortExpression="Occupation" />
            <asp:BoundField DataField="sub_Occupation" HeaderText="sub_Occupation" 
                SortExpression="sub_Occupation" />

        </Columns>
    </asp:GridView>
    <asp:Label ID="lbl" runat="server" Text="Label"></asp:Label>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
        DeleteMethod="Delete" InsertMethod="Insert" 
        OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
        TypeName="IMAM_APPLICATION.DSContactTableAdapters.contact_infoTableAdapter" 
        UpdateMethod="Update">
        <DeleteParameters>
            <asp:Parameter Name="Original_idcontact_info" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>

            <asp:Parameter Name="Work_Field" Type="String" />
            <asp:Parameter Name="Occupation" Type="String" />
            <asp:Parameter Name="sub_Occupation" Type="String" />

            <asp:Parameter Name="Original_idcontact_info" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Work_Field" Type="String" />
            <asp:Parameter Name="Occupation" Type="String" />
            <asp:Parameter Name="sub_Occupation" Type="String" />
        </InsertParameters>
    </asp:ObjectDataSource>

  <asp:DropDownList ID="cmbWorkField" runat="server" Style="top: 715px; left: 180px;
                    position: absolute; height: 22px; width: 126px">


                </asp:DropDownList>

                <asp:DropDownList runat="server" ID="cmbOccupation" Style="top: 745px; left: 180px;
                    position: absolute; height: 22px; width: 77px">

                </asp:DropDownList>
                <asp:DropDownList ID="cmbSubOccup" runat="server" 
                    style="position:absolute; top: 775px; left: 180px;">

                </asp:DropDownList>

                <cc1:CascadingDropDown ID="cmbWorkField_CascadingDropDown" runat="server" 
                    TargetControlID="cmbWorkField" 
                    Category="WorkField"  
                    LoadingText="Please Wait ..." 
                    PromptText="Select Wor kField ..." 
                    ServiceMethod="GetWorkField" 
                    ServicePath="ServiceTags.asmx">
                </cc1:CascadingDropDown>

                <cc1:CascadingDropDown ID="cmbOccupation_CascadingDropDown" runat="server" 

                    TargetControlID="cmbOccupation"
                     Category="Occup" 
                    LoadingText="Please wait..." 
                    PromptText="Select Occup ..." 
                    ServiceMethod="GetOccup" 
                    ServicePath="ServiceTags.asmx" 
                    ParentControlID="cmbWorkField">
                </cc1:CascadingDropDown>
                <cc1:CascadingDropDown ID="cmbSubOccup_CascadingDropDown" runat="server" 
                    Category="SubOccup" 
                    Enabled="True"
                     LoadingText="Please Wait..." 
                    ParentControlID="cmbOccupation" 
                    PromptText="Select Sub Occup" 
                    ServiceMethod="GetSubOccup" 
                    ServicePath="ServiceTags.asmx" 
                    TargetControlID="cmbSubOccup">
                </cc1:CascadingDropDown>


</asp:Content>
......................................................
C#  code behind
......................................................

   protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
             string strg = GridView1.SelectedDataKey["idcontact_info"].ToString();
            int index = Convert.ToInt32(GridView1.SelectedDataKey["idcontact_info"].ToString());
            //txtSearch.Text = GridView1.SelectedIndex.ToString();
           // txtSearch.Text = GridView1.SelectedDataKey["idcontact_info"].ToString();

            DSContactTableAdapters.contact_infoTableAdapter GetByIDAdapter = new DSContactTableAdapters.contact_infoTableAdapter();


            DSContact.contact_infoDataTable ByID = GetByIDAdapter.GetDataByID(index);
            //DSSearch.contact_infoDataTable FirstName = FirstNameAdapter.GetDataByFirstNameList(prefixText);
            foreach (DataRow dr in ByID.Rows)
            {
                lbl.Text = dr["Work_Field"].ToString() + "....." + dr["Occupation"].ToString() + "....." + dr["sub_Occupation"].ToString();


            cmbWorkField_CascadingDropDown.SelectedValue = dr["Work_Field"].ToString();
            cmbOccupation_CascadingDropDown.SelectedValue = dr["Occupation"].ToString();
            cmbSubOccup_CascadingDropDown.SelectedValue = dr["sub_Occupation"].ToString();


            }
        }
.......................................................
web Service 
.......................................................
 [WebMethod]
        public CascadingDropDownNameValue[] GetWorkField(string knownCategoryValues, string category)
    {

        //dsCarsTableAdapters.CarsTableAdapter makeAdapter = new dsCarsTableAdapters.CarsTableAdapter();
        //dsCars.CarsDataTable makes = makeAdapter.GetAllCars();
        DSContactTableAdapters.tag_work_fieldTableAdapter GetWorkFieldAdapter = new DSContactTableAdapters.tag_work_fieldTableAdapter();
        DSContact.tag_work_fieldDataTable WorkFields = GetWorkFieldAdapter.GetDataByGetWorkField();
        List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
        foreach (DataRow dr in WorkFields)
        {
            string Work_Field = (string)dr["work_Field_name"];
            int idtag_work_field = (int)dr["idtag_work_field"];
            values.Add(new CascadingDropDownNameValue(Work_Field, idtag_work_field.ToString()));
        }
        return values.ToArray();
    }

    [WebMethod]
    public CascadingDropDownNameValue[] GetOccup(string knownCategoryValues, string category)
    {
        StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
        int idtag_work_field;
        if (!kv.ContainsKey("WorkField") || !Int32.TryParse(kv["WorkField"], out idtag_work_field))
        {
            return null;
        }
        //dsCarModelsTableAdapters.CarModelsTableAdapter modelAdapter = new dsCarModelsTableAdapters.CarModelsTableAdapter();
        //dsCarModels.CarModelsDataTable models = modelAdapter.GetModelsByCarId(makeId);
        DSContactTableAdapters.tag_OccupTableAdapter GetOccupAdapter = new DSContactTableAdapters.tag_OccupTableAdapter();
        DSContact.tag_OccupDataTable Occups = GetOccupAdapter.GetByOccup_ID(idtag_work_field);
        //           
        List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
        foreach (DataRow dr in Occups)
        {
            values.Add(new CascadingDropDownNameValue((string)dr["Occup_Name"], dr["idtag_Occup"].ToString()));
        }
        return values.ToArray();
    }

    [WebMethod]
    public CascadingDropDownNameValue[] GetSubOccup(string knownCategoryValues, string category)
    {
        StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
        int idtag_Occup;
        if (!kv.ContainsKey("Occup") || !Int32.TryParse(kv["Occup"], out idtag_Occup))
        {
            return null;
        }

        //dsModelColorsTableAdapters.ModelColorsTableAdapter adapter = new dsModelColorsTableAdapters.ModelColorsTableAdapter();
        //dsModelColors.ModelColorsDataTable colors = adapter.GetColorsByModelId(colorId);

        DSContactTableAdapters.tag_Sub_OccupTableAdapter GetSubOccupAdapter = new DSContactTableAdapters.tag_Sub_OccupTableAdapter();
        DSContact.tag_Sub_OccupDataTable SubOccups = GetSubOccupAdapter.GetDataBy_Sub_Occup_ID(idtag_Occup);
        List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
        foreach (DataRow dr in SubOccups)
        {
            values.Add(new CascadingDropDownNameValue((string)dr["Sub_Occup_Name"], dr["idtag_Sub_Occup"].ToString()));
        }
        return values.ToArray();
    }

UPDATE:

my master page
...................................
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Master.master.cs" Inherits="IMAM_APPLICATION.Master" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <%--<asp:ScriptManager ID="ScriptManager1" runat="server" />--%>
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ToolkitScriptManager>


    </div>
     <div>

        <table class="style1" frame="vSides">
            <tr>
                <td class="style17" bgcolor="#FFFF99">
                </td>
                <td class="style18" style="">
                    <img alt="" src="Images/banner1.gif" 
                        style="width: 950px; height: 89px; margin-bottom: 0px;" /></td>
                <td class="style17" bgcolor="#FFFF99">
                </td>
            </tr>
            <tr>
                <td class="style15">
                </td>
                <td class="style16" bgcolor="#FFFF99">
                    <asp:Menu ID="Menu1" runat="server" Width="44px" Orientation="Horizontal" 
                        DataSourceID="SiteMapDataSource1" BackColor="#FFFBD6" 
                        DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em" 
                        ForeColor="#990000" StaticDisplayLevels="2" StaticSubMenuIndent="10px">
                        <StaticMenuStyle BorderStyle="Dotted" />
                        <StaticSelectedStyle BackColor="#FFCC66" />
                        <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                        <DynamicHoverStyle BackColor="#990000" ForeColor="White" />
                        <DynamicMenuStyle BackColor="#FFFBD6" />
                        <DynamicItemTemplate>
                            <%# Eval("Text") %>
                        </DynamicItemTemplate>
                        <DynamicSelectedStyle BackColor="#FFCC66" />
                        <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                        <StaticHoverStyle BackColor="#990000" ForeColor="White" />
                        <StaticItemTemplate>
                        <%# Eval("Text") %>
                        </StaticItemTemplate>
                    </asp:Menu>

                </td>
                <td class="style15">
                </td>
            </tr>
            <tr>
                <td class="style19" bgcolor="#FFFF99">
                </td>
                <td class="style20">
                    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">



                    </asp:ContentPlaceHolder>

                </td>
                <td class="style19" bgcolor="#FFFF99">
                </td>
            </tr>
            <tr>
                <td class="style7">
                </td>
                <td class="style8" style="" bgcolor="#FFFF99">


                    Copyright&nbsp; Imam Mahdi Association of Marjeya</td>
                <td class="style7">
                </td>
            </tr>
        </table>

    </div>
     <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />

    </form>
</body>
</html>
  • 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-26T20:13:05+00:00Added an answer on May 26, 2026 at 8:13 pm

    Simple; set the SelectedValue property of CascadingDropDown control, instead of DropDown control. It’s working for me.

    Eg. CascadingDropDown1.SelectedValue = "KY"

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

Sidebar

Related Questions

Greetings, I have problem with errorPlacement, I'm trying to place the error message next
Greetings, I have a problem using jqgrid and jquery tab (I am coding in
Greetings, I have to following problem. I have a WCF Service which runs under
Greetings! I have a Repeater control that's using an XmlDataSource control. <asp:FormView id=myFormView runat=server
Greetings, I have a problem as follows: I have an SQL variable declared: DECLARE
Greetings, Problem: I have a main view, that already is associated with a xib
Greetings, I have a problem in my application I'm building in. To give the
Greetings folks. I have this weird problem. In the project I'm working on now,
Greetings Stackoverflowers, I have an application in which a communication abstraction layer exists. Each
Greetings all, I'm an AJAX newbie, and I'm having a problem with same origin

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.