Cascading Drop Down Multiple Parents?

Rate It (1)

Last post 12-09-2009 12:14 PM by klou. 11 replies.

Sort Posts:

  • Cascading Drop Down Multiple Parents?

    06-11-2008, 4:12 PM
    • Member
      11 point Member
    • wndrboy2k3
    • Member since 05-23-2008, 11:12 PM
    • Posts 41

    Hey Guys,

    I'm working on a cascading drop down setup that breaks down the make model year and style of car. I have it working up to the Year but can't get the style going. The problem is, my tableadapter for style requires that two conditions be fullfilled to pull a the style... The Make and the year. How would I get that information passed through properly?
     

  • Re: Cascading Drop Down Multiple Parents?

    06-17-2008, 6:04 AM

    Hi wndrboy2k3,

    Based on my understanding, you have three DropDrowLists tied to the CascadingDropDown -- the ddlMake, the ddlYear and the ddlStyle. And the relation of the Categories is that the Style is filtered by both the Make and the Year. I couldn’t image that whether there is any relation between the Make and the Year or not. So, there are two ways you can follow:

    1. If the Make control the Year

    In this situation, please refer to my another thread which has similar request here: Cascading Dropdowns picking one of either first two

        2.   There is no relation between them

    Each of the two DropDownLists – the ddlMake, theddlYear could get data from the DataBase separately. Then, we simply need to tie both of them to the DataBase. And, in the SelectedChange events of them, tie the filtered Data to the ddlStyle. There is no need to use the CascadingDropDown Control if more than one parent can control the child control.

    Note:

    1. Place all of the Controls into an UpdatePanel, and set the property AutoPostBack as true. Then, the behavior of selection change would seem more smooth.
    2. Add this code “EnableEventValidation="false"” into the page code, otherwise, an error “Sys.WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument.” would be thrown.

    Have my suggestions achieved your goal?

    Best regards,

    Zhi-Qiang Ni

    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
    Answer” if a marked post does not actually answer your question.
  • Re: Cascading Drop Down Multiple Parents?

    06-17-2008, 6:51 PM
    • Member
      11 point Member
    • wndrboy2k3
    • Member since 05-23-2008, 11:12 PM
    • Posts 41

     Hi! Thank you for taking the time to reply. My issue is actually different from the solution that you've provided.

     I'm using the Cascading Dropdown Extender from the ajax toolkit and have 4 dropdown tables.

     

    - Makes

    -Models

    -Year

    -Style

     

    The table adapters are using stored procedures to grab the value. The modeltableadapter users @makeID and the year uses @modelID. However the stored procedure for the Styletableadapter requires 2 parameters

    -@ModelID

    -@Year

     to return the values, I'm wondering how I can provide both the values.


    Thansks!

  • Re: Cascading Drop Down Multiple Parents?

    06-17-2008, 10:50 PM
    Answer

    Hi wndrboy2k3,

    To access the two parameters – @ModelID & @Year, we simply need to find them from the “knownCategoryValues” which is sent to the final CascadingDropDown control’s ServiceMethod as a parameter.

    For example, let’s have a look at the sample method which demonstrates how the Model control the Color: 

        <WebMethod()> _
        Public Function GetColors(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()
            Dim kv As StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)
    
            Dim ModelId As Integer
            If ((Not kv.ContainsKey("Model")) Or (Not Int32.TryParse(kv("Model"), ModelId))) Then
                Return Nothing
            End If
    
            Dim carColorAdapter As New dsModelColorsTableAdapters.ModelColorsTableAdapter()
    
            Dim colorValues As New List(Of CascadingDropDownNameValue)()
            For Each row As DataRow In carColorAdapter.GetColorsByModelId(ModelId)
                colorValues.Add(New CascadingDropDownNameValue(row("ColorName").ToString(), row("ColorId").ToString()))
            Next
    
            Return colorValues.ToArray()
        End Function
    Similarly, we may get the @Year like this 
            Dim Year As Integer
            If ((Not kv.ContainsKey("Year")) Or (Not Int32.TryParse(kv("Year"), Year))) Then
                Return Nothing
            End If
    If each two CascadingDropDowns has grade by grade relationship between parent and child, all the Category names and the selected values will be saved in the “knownCategoryValues” in the format “Make:XXXX;Modal:XXXX;Year:XXXX;” (XXXX is the value). Thus, we can get either of the Categories’ selected value.

    You may download the sample code by referring the tutorial video here: http://www.asp.net/learn/ajax-videos/video-278.aspx

    Have my suggestions achieved your goal?

    Best regards,

    Zhi-Qiang Ni

    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
    Answer” if a marked post does not actually answer your question.
  • Re: Cascading Drop Down Multiple Parents?

    06-18-2008, 12:12 AM
    • Member
      11 point Member
    • wndrboy2k3
    • Member since 05-23-2008, 11:12 PM
    • Posts 41

    I'm trying really hard to under stand how this code works (huge part of the problem) going through the debugging i learned what you were saying about the Make: 3 Model:5 year:1900 being returned as the kv.

     However i just tried doing this

     

     <WebMethod()> _
        <Script.Services.ScriptMethod()> _
    Public Function GetStyles(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()
            Dim kv As StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)

            Dim theyear As Integer
            If ((Not kv.ContainsKey("Year")) Or (Not Int32.TryParse(kv("Year"), theyear))) Then
                Return Nothing
            End If

            Dim id As Integer
            If ((Not kv.ContainsKey("Model")) Or (Not Int32.TryParse(kv("Model"), id))) Then
                Return Nothing
            End If

            Dim StylesAdapter As New dsStylesTableAdapters.GW_GetVehicleStylesTableAdapter

            Dim StyleValues As New List(Of CascadingDropDownNameValue)()
            For Each row As DataRow In StylesAdapter.GetStyles()
                StyleValues.Add(New CascadingDropDownNameValue(row("DSC").ToString(), row("BODY_STYLE_ID").ToString()))
            Next

            Return StyleValues.ToArray()
        End Function

     

    and the "StylesAdapter.GetStyles()" says "Error    3    Argument not specified for parameter 'id' of 'Public Overridable Overloads Function GetStyles(id As Integer?, theyear As Integer?) As dsStyles.GW_VehicleStylesDataTable'. "

     

  • Re: Cascading Drop Down Multiple Parents?

    06-18-2008, 12:31 AM

    Hi wndrboy2k3,

    The service method would be fired when its parent control end the selection.

    If your stored procedure for the Styletableadapter requires 2 parameters, why didn’t you send the id & theyear into the GetStyles function?

    Please try this code:  

    For Each row As DataRow In StylesAdapter.GetStyles(id, theyear)
    And, I strongly recommend that you refer to that video tutorial which I have provided and download the sample code.

    Please let me know whether this helps or not.

    Best regards,

    Zhi-Qiang Ni

    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
    Answer” if a marked post does not actually answer your question.
  • Re: Cascading Drop Down Multiple Parents?

    06-18-2008, 12:40 AM
    • Member
      11 point Member
    • wndrboy2k3
    • Member since 05-23-2008, 11:12 PM
    • Posts 41

     hi there, i have watched that video a million times, which is how i got it work the first 3 ddls. However when it came to getting 2 parameters, i was clear i didn't understand the code. your posts have completely solved this for me. You are amazing! Thank you for your time and patience.

  • Re: Cascading Drop Down Multiple Parents?

    06-18-2008, 12:52 AM

    Hi wndrboy2k3,

    I’m very glad that your issue is resolved. Don’t hesitate to let me know if you have any other difficulties to follow.

    Best regards,

    Zhi-Qiang Ni

    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
    Answer” if a marked post does not actually answer your question.
  • Re: Cascading Drop Down Multiple Parents?

    09-15-2008, 8:08 AM
    • Member
      8 point Member
    • sureshkaki
    • Member since 06-14-2006, 7:29 AM
    • Posts 10

    hi zhi-qiand ni-msft,

                    i have four dropdown list box.second ddl is dependent on first ddl and third ddl is dependent on 1st and 2nd and 4th dll is dependent on 1st,2nd and 3rd.how to implement it using  Cascading Drop Down .you can say that i have to use multiple parents for child.on every selection value in dropdown others will be get populated .

     

     Regards,

    Suresh 

  • Re: Cascading Drop Down Multiple Parents?

    09-15-2008, 10:49 PM

    Hi Suresh,

    Actually, your request is the base usage of the CascadingDropDown. There is no need to use multiple parents, we simply need to follow the sample video’s steps. It is important that the DB should be built with parent-child relational categories.

    Please download the code of the tutorial video http://www.asp.net/learn/ajax-videos/video-278.aspx.

    Any other questions about using the CascadingDropDown, please post a new thread.

    Best regards,

    Zhi-Qiang Ni

    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
    Answer” if a marked post does not actually answer your question.
  • Cascading Drop Down Single Parent - Multiple Child

    06-30-2009, 8:16 AM
    • Member
      2 point Member
    • ty_kishore
    • Member since 06-30-2009, 12:11 PM
    • Posts 1

    Hi Zhi In my project, i have a requirement where in i have 6 dropdowns. 1.Make 2.Model 3.Transmission 4.Boby 5.Fuel 6.Drive Model is dependant on Make. I could implement this successfully. Now Transmission, Body, Fuel, Drive are dependant on Model.. Not sure how to do this one.. Basically when user chooses a value from Model, remaining 4 dropdowns should be populated. I could do this in a normal ASP.Net. But client is insisting on using cascading dropdown. Kindly share your thoughts. Rgds Kishore

  • Re: Cascading Drop Down Multiple Parents?

    12-09-2009, 12:14 PM
    • Member
      2 point Member
    • klou
    • Member since 12-09-2009, 11:46 AM
    • Posts 1

    I have the same problem, and Could not find a solution. 

    The cascadingDropdown sample from ASP.net AJAX has the same problem.

    Let's say, I set a breakpoint in DropDownList3_SelectedIndexChanged event in this sample, and I run it in debug mode so that it will stop to run everytime the event is fired. Then I select Acura in dropdown list Make and Integra in the second dropdown list, and Green in the third dropdown list. the DropDownList3_SelectedIndexChanged event is fired. I select "Please select a make" in the first dropdown list again, the second one and third dropdown lists return to default. once again, I select Acura in dropdown list Make and Integra in the second dropdown list, and Green in the third dropdown list. the DropDownList3_SelectedIndexChanged event IS NOT FIRED. If I select a different color in the color dropdown list, the event IS FIRED. Is it possible to make this event is fired everytime? Many thanks

    Klou  

     

     

     

Page 1 of 1 (12 items)