Click here to Skip to main content
13,661,165 members
Rate this:
 
Please Sign up or sign in to vote.
Hi All,
I have a cascading dropdownlist in a datalist .I need to assign the selectedvalue of cascading dropdown from code behind ie on another dropdownlist selected index changed.However I cant find the casacding dropdown in codebehind .Any help will be really appreciated.Thanks in advance.

What I have tried:

 <asp:DropDownList ID="ddl_eddriver" class="w3-input w3-border w3-round" Width="180px" runat="server" TabIndex="15"></asp:DropDownList> 
<asp:CascadingDropDown ID="CascadingDropDown5" runat="server"    Category="driver" TargetControlID="ddl_eddriver"  PromptText="[Select Driver]"    

LoadingText="Loading Driver's..."                                             ServicePath="~/Service/SSS.asmx"                          ServiceMethod="GetDropDownDrivers" Enabled="True">
</asp:CascadingDropDown>


 protected void ddl_editclnt_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList ddl_editclnt = sender as DropDownList;
            
            //get the namingcontainer from the dropdownlist and cast it as a datalistitem
            DataListItem item4 = ddl_editclnt.NamingContainer as DataListItem;
            objcon.GetReader("select IN021_01,ISNULL((select  IN002_01 FROM IN002_05 WHERE IN002_04.IN002_04_00=IN002_05.IN002_04_00),'') as driver from in021 inner join IN002_04 ON IN021.IN002_04_00=IN002_04.IN002_04_00  where IN021.IN021_01='" + ddl_editclnt.SelectedValue.ToString() + "'");
            if (objcon.dr.Read())
            {
                foreach (DataListItem item in this.DataList2.Items)
                {
                    DropDownList ddl_eddriver = item.FindControl("ddl_eddriver") as DropDownList;
                    
                    ddl_eddriver.SelectedValue = objcon.dr["driver"].ToString(); //I am getting error here
                    UpdatePanel2.Update();

                 }
                }
}
Posted 2 days ago
Comments
   
What's the value of objcon.dr["driver"]?
yesterday
   
Its's an integer value.
   
I mean are you getting null for that object?
2hrs 15mins ago
   
no

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web01-2016 | 2.8.180810.1 | Last Updated 12 Aug 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100