CascadingDropDown SelectedValue not working?

May 10, 2007 at 6:10 PM
Hello All,

I am using ASP.NET AJAX Control Toolkit's tool - CascadingDropDown to have 4 dropdowns with the parent control as the previous one. It fills this dropdowns using WebService as specified here:

http://ajax.asp.net/ajaxtoolkit/Walkthrough/CCDWithDB.aspx

Now all the parts are working as they should be. DropDowns get data from webservice and fills. What I want is a way to change SelectedValue for CascadingDropDowns from code-behind (even using javascript or querystring is fine). I know that original DropDownLists does not allowing changing SelectedIndex since there is CascadingDropDown associated with it.

Here are the various methods that I have tried with no success in code behind (none give errors, they just dont set selected value):
  CascadingDropDown4.SelectedValue = "00005"
'OR
  CascadingDropDown4.SelectedValue = "00005:::00005"
'OR
  CascadingDropDown4.SelectedValue = "abc"
'OR
        Dim ccddtowns As CascadingDropDown = Me.FindControl("CascadingDropDown4")
        ccddtowns.SelectedValue = String.Empty
        ccddtowns.SelectedValue = "00005"

-------------------------------------aspx page below-----------------
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Top.aspx.vb" Inherits="_Default" Theme="Default" EnableEventValidation="false"%>
 
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
 
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
   
<!--<!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>Top Frame</title> 
</head>
<body>
    <form id="form1" runat="server">
    <div id="header">
        <div id="top">
            <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            <table cellpadding="2" cellspacing="0">
                <tr>
                    <td>
                        <asp:DropDownList ID="DdlCounty" runat="server">
                        </asp:DropDownList></td>
                    <td>
                        <asp:DropDownList ID="DdlDocket" runat="server">
                        </asp:DropDownList></td>
                    <td>
                        <asp:DropDownList ID="DdlBook" runat="server">
                        </asp:DropDownList></td>
                    <td>
                        <asp:DropDownList ID="DdlPage" runat="server" AutoPostBack="True">
                        </asp:DropDownList></td>
                    <td>
                        <asp:Button ID="BtnPagePrev" runat="server" Text="<<" CssClass="button" />
                    </td>
                    <td>
                <asp:Button ID="BtnPageNext" runat="server" Text=">>" CssClass="button" /></td>
                </tr>
            </table>
        </div>
      
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <IFRAME runat=server id="frame1" scrolling="no" width="100%" height="600px" frameborder="no">
                </IFRAME>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="DdlPage" EventName="SelectedIndexChanged" />
                <asp:AsyncPostBackTrigger ControlID="BtnPageNext" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="BtnPagePrev" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>    
         
        <ajaxToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="DdlCounty"
        Category="County"  PromptText="County..."  LoadingText="[Busy...]"
        ServicePath="WebService.asmx" ServiceMethod="GetCounties"/>
        <ajaxToolkit:CascadingDropDown ID="CascadingDropDown2" runat="server" TargetControlID="DdlDocket"
        Category="Docket"  PromptText="Docket..."  LoadingText="[Busy...]"
        ServicePath="WebService.asmx" ServiceMethod="GetDockets" ParentControlID="DdlCounty" />
        <ajaxToolkit:CascadingDropDown ID="CascadingDropDown3" runat="server" TargetControlID="DdlBook"
        Category="Book"  PromptText="Book..."  LoadingText="[Busy...]"
        ServicePath="WebService.asmx" ServiceMethod="GetBooks" ParentControlID="DdlDocket" />
        <ajaxToolkit:CascadingDropDown ID="CascadingDropDown4" runat="server" TargetControlID="DdlPage"
        Category="Page"  PromptText="Page..."  LoadingText="[Busy...]"
        ServicePath="WebService.asmx" ServiceMethod="GetPages" ParentControlID="DdlBook"/>
    </div>                
    </form>      
</body>
 
    <!-- Code to dynamically resize iframe's height: Tested in IE7-->
    <script language=Javascript>  
    /*
        function js_resize()
        {
            var bodyh = document.body.offsetHeight;
            var headerh = document.getElementById('header').offsetHeight;
            var extrah = document.getElementById('extra').offsetHeight;
            var navh = document.getElementById('navigation').offsetHeight;
            var iframeh = bodyh-headerh-extrah;
           
            //alert(iframeh + "=" + bodyh + "-" + headerh + "-" + extrah + " navh=" + navh)
            if (iframeh > navh)
                document.getElementById('frame1').style.height = iframeh;
            else
                document.getElementById('frame1').style.height = navh;
        }
        */
         
        window.onresize= js_resize;
    
        function js_resize()
        {
            var bodyh = document.body.offsetHeight;
            var toph = document.getElementById('top').offsetHeight;
            document.getElementById('frame1').style.height = bodyh-toph;
        } 
        //js_resize();
                   
        //function js_inc1()
        //{
            //document.getElementById("navigation").style.width=260;
            ////alert("inc1");
        //}
        //Next line updates iframe size when just the update panel is refresheds
       
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(js_resize);
    </script>
   
</html> 
 
May 26, 2007 at 12:40 AM
This forum is for CodePlex web site issues and discussion only. Please re-post your question to the appropriate project's forum.

Thanks!