Page view counter

CascadingDropDown not populating

Last post 12-22-2006 7:05 PM by David Anson. 16 replies.

Sort Posts:

  • CascadingDropDown not populating

    05-07-2006, 7:21 PM
    • Loading...
    • lestat
    • Joined on 05-07-2006, 10:31 PM
    • New Zealand
    • Posts 8

    Hi

    I'm trying to use the CascadingDropDown with a database in VB, using page methods.

    My three DropDownLists are drpProject, drpFixFor and drpFixForSub. The drpProject control is populated fine when the page loads; and I'd expect the drpFixFor control to be populated when drpProject is changed, however, this is not happening.

    The drpFixFor control is being enabled, but not populated - my "GetFixForList" function doesn't appear to be called at all. (I put a breakpoint in it, and the breakpoint isn't hit.)

    Interestingly, if I remove ParentControlID="drpProject" from drpFixFor's extender, the function is called as expected when the page loads.

    My aspx page is:

    <%

    @ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Test.aspx.vb" Inherits="Test" Title="" %>

    <%

    @ Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="atlasToolkit" %>

    <

    asp:Content ID="Content1" ContentPlaceHolderID="cphBody" runat="Server">

    <table>

       <tr>

          <td style="width: 100px">Project:</td>

          <td><asp:DropDownList ID="drpProject" runat="server" /></td>

       </tr>

       <tr>

          <td style="width: 100px">Fix For:</td>

          <td><asp:DropDownList ID="drpFixFor" runat="server" /></td>

       </tr>

       <tr>

          <td style="width: 100px">Fix For Sub:</td>

          <td><asp:DropDownList ID="drpFixForSub" runat="server" /></td>

       </tr>

    </table>

    <atlasToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server">

       <atlasToolkit:CascadingDropDownProperties TargetControlID="drpProject" Category="Project" PromptText="(Select One)" ServiceMethod="GetProjectList" />

       <atlasToolkit:CascadingDropDownProperties TargetControlID="drpFixFor" Category="FixFor" PromptText="(Select One)" ParentControlID="drpProject" ServiceMethod="GetFixForList" />

       <atlasToolkit:CascadingDropDownProperties TargetControlID="drpFixForSub" Category="FixForSub" PromptText="(Select One)" ParentControlID="drpFixFor" ServiceMethod="GetFixForSubList" />

    </atlasToolkit:CascadingDropDown>

    </

    asp:Content>

    And my Code Behind page is:

    Imports

    AtlasControlToolkit

    Imports

    System.Web.Services

    Partial

    Class Test

       Inherits System.Web.UI.Page

       <WebMethod()> _

       Public Function GetProjectList(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()

          Dim values As New Generic.List(Of CascadingDropDownNameValue)

          For Each myProject As Project In Project.GetList

             values.Add(

    New CascadingDropDownNameValue(myProject.Name, myProject.ID))

          Next

          Return values.ToArray

       End Function

       <WebMethod()> _

       Public Function GetFixForList(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()

          Dim values As New Generic.List(Of CascadingDropDownNameValue)

          ' Hardcode to Project "2" for debugging

          For
    Each myFixFor As FixFor In
    FixFor.GetList(2)

             values.Add(

    New CascadingDropDownNameValue(myFixFor.Name, myFixFor.ID))

          Next

          Return values.ToArray

       End Function

    End

    Class

    Note: "Project" and "FixFor" are objects defined in my App_Code folder, and their "GetList" functions return data from the SQL database.

    Any ideas?

    Thanks,
    Andrew

  • Re: CascadingDropDown not populating

    05-08-2006, 11:28 AM
    • Loading...
    • pratibk
    • Joined on 05-01-2006, 12:46 PM
    • Posts 43

    I am also facing some issues with the cascadingdropdown extender, my question is that what if my database schema is such that i dont have ID for the fields in the drop downs, cant i fetch the value in the second drop down with the string value in the first drop down. As i understand this, ID seems to be added mandatorily in this extender.

     

    -Pratibha

  • Re: CascadingDropDown not populating

    05-08-2006, 1:46 PM
    • Loading...
    • sburke_msft
    • Joined on 04-04-2006, 7:28 PM
    • Redmond, WA
    • Posts 770
    • AspNetTeam

    I don't see anything wrong with your code - what happens if you change all three service method's to call the one that's workng?  Does it get called then?

    Pratibha - I don't understand your question.  ID isn't added by the extender at all - you can put whatever you want into the value field of the CascadingDropDownNameValue.

    Don't forget, this posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: CascadingDropDown not populating

    05-09-2006, 6:40 AM
    • Loading...
    • pratibk
    • Joined on 05-01-2006, 12:46 PM
    • Posts 43
    hey shawn, now i get it..hadnt looked carefully  through the tool kit code earlier. It makes sense now and the cascadingdropdown works perfectly :)
  • Re: CascadingDropDown not populating

    05-09-2006, 12:42 PM
    • Loading...
    • sburke_msft
    • Joined on 04-04-2006, 7:28 PM
    • Redmond, WA
    • Posts 770
    • AspNetTeam
    Cool!
    Don't forget, this posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: CascadingDropDown not populating

    05-09-2006, 6:07 PM
    • Loading...
    • lestat
    • Joined on 05-07-2006, 10:31 PM
    • New Zealand
    • Posts 8

    Hi

    I've tried setting all three service methods to call GetProjectList, and still no luck - the function's called once when the page is loaded to populate the first DropDown, and not called for the others.

    Thanks,
    Andrew

  • Re: CascadingDropDown not populating

    05-09-2006, 8:55 PM
    Answer

    To fix this, you need to add EnableEventValidation="false" to your Page directive. This should be a FAQ for CascadingDropDown, but basically ASP.NET tries to make sure that postbacks don't contain stuff they shouldn't based on what it knows about the page it sent down. Well, CDD is all about sending back data that wasn't in the page to begin with, so this feature needs to be disabled for pages that use it.

    That's the good news. :) The bad news (or better news depending on how you see it) is that this should have been easier to debug. CDD tries to populate the list with error details when an error occurs (see _onMethodError), but it doesn't because a change some time ago to use name/value pairs for the data type wasn't applied to the error methods. I've logged this for fixing in the next release.

    But for now, your issue should be trivially solvable by flipping EnableEventValidation as I note above.

    Thanks!


    http://blogs.msdn.com/Delay

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: CascadingDropDown not populating

    05-09-2006, 9:51 PM
    • Loading...
    • lestat
    • Joined on 05-07-2006, 10:31 PM
    • New Zealand
    • Posts 8

    Fantastic - that did the job!

    Thanks
    Andrew

  • Re: CascadingDropDown not populating

    05-15-2006, 5:10 AM
    • Loading...
    • columba
    • Joined on 08-17-2004, 9:17 AM
    • Posts 11
    nice1 David,

    that had really thrown me, thought it was a vb.net thing.  the debugging experience on this could definitely be improved on but at least it's in the forums.

    thanks
    "Nothing astonishes men so much as common sense and plain dealing." (1841), Ralph Waldo Emerson
  • Re: CascadingDropDown not populating

    05-19-2006, 2:26 PM
    • Loading...
    • doshea
    • Joined on 05-06-2006, 9:46 AM
    • Posts 5

    I've been trying to get this example to work so as I can use similar in my own pet project.

    Would anyone be kind enough to tell\show me how to create the "Projects" and "FixFor" objects which are defined in the App_Code folder.

    I'm getting errors on this line

    For Each myProject As Project In Project.GetData

    How do I define Project in the TableAdapter?

    Rgds

    DOShea

  • Re: CascadingDropDown not populating

    08-15-2006, 11:36 AM
    • Loading...
    • your_kanth
    • Joined on 04-17-2006, 4:05 PM
    • Posts 6

    Hi,

                    My parent dropdown itself is not population. I added EnableEventValidation="false" in page tag. Still no luck.

                    If i work in " atlas web project", I am able sccess with cascading dropdown. But if i try to do with existing project, i am not able to. No error but first dropdown itself not populating.

    I added in web.config

    <

    pages>

    <

    controls>

    <

    add namespace="Microsoft.Web.UI" assembly="Microsoft.Web.Atlas" tagPrefix="atlas"/>

    <

    add namespace="Microsoft.Web.UI.Controls" assembly="Microsoft.Web.Atlas" tagPrefix="atlas"/>

    </

    controls>

    ....

    </

    pages>

    This is my aspx page code:

    <%

    @ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" EnableEventValidation="false" %>

    <%

    @ Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="atlasToolkit" %>

    <form id="form1" runat="server">

    <atlas:ScriptManager ID="ScriptManager1" runat="server" />

    <div><asp:DropDownList ID="DropDownList1" runat="server">

    </asp:DropDownList><asp:DropDownList ID="DropDownList2" runat="server">

    </asp:DropDownList></div>

    <atlasToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server">

    <atlasToolkit:CascadingDropDownProperties TargetControlID="DropDownList1" Category="Make" PromptText="Please select a make" ServiceMethod="GetDropDownContentsPageMethod" />

    <atlasToolkit:CascadingDropDownProperties TargetControlID="DropDownList2" Category="Model" PromptText="Please select a model" ServicePath="CarService.asmx" ServiceMethod="GetProductGroups" ParentControlID="DropDownList1" />

    </atlasToolkit:CascadingDropDown>

    </form>

    .Vb File:      

    <WebMethod()> _

    Public Function GetDropDownContentsPageMethod(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()

    Dim values As List(Of CascadingDropDownNameValue) = New List(Of CascadingDropDownNameValue)

    values.Add(

    New CascadingDropDownNameValue("A", "1"))

    values.Add(

    New CascadingDropDownNameValue("B", "2"))

    values.Add(

    New CascadingDropDownNameValue("C", "3"))

    Return values.ToArray

    End Function

     

    My WebService (CarService.vb):

    <WebMethod()> _

    Public Function GetProductGroups(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()

    Dim kv As StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)

    Dim values As List(Of CascadingDropDownNameValue) = New List(Of CascadingDropDownNameValue)

    Dim ProvinceId As Integer

    If (kv.ContainsKey("Make") And Int32.TryParse(kv("Make"), ProvinceId)) Then

    If ProvinceId = 1 Then

    values.Add(

    New CascadingDropDownNameValue("a", "1"))

    ElseIf ProvinceId = 2 Then

    values.Add(

    New CascadingDropDownNameValue("b", "1"))

    End If

    End If

    Return values.ToArray

    End Function

    Any help is highly Appreciated.

     

    Regards

    kant.

  • Re: CascadingDropDown not populating

    08-15-2006, 3:37 PM

    My reply from the private email about this issue:

    "The web.config for an Atlas has additional settings that aren't present in a defau