+ Reply to Thread
Results 1 to 3 of 3

Thread: Updating DDL inside DataList OnChange of DDL outside DataList

  1. #1
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Updating DDL inside DataList OnChange of DDL outside DataList

    OK. I have a datalist containing a number of controls, textboxes and dropdownlists. The relevant ones for this problem are:-
    Source
    PremiumType
    SourcePolicyRef

    I have another DDL, category within the Page, outside the datalist.

    When the category is changed within the page, I need to retrieve the selectedvalue of Source and if it's 1 or 4, update the PremiumType or, if it's 2 or 3, update the SourcePolicyRef based on the new category.

    This is what I have:-
    The DDL called when the category is changed.
    Code:
        Sub ddl_change_category(ByVal s As Object, ByVal e As EventArgs)
            change_category(ddl_category.SelectedValue)
            build_premiumtype(ddl_category.SelectedValue, ddl_premiumtype)
        End Sub
     
        Sub change_category(ByVal category)
    'there is some more code here that just handles controls within the page
    .
    .
    .
                For Each item As DataListItem In dlst_premiums.Items
                    If item.ItemType = ListItemType.Item Or item.ItemType = ListItemType.AlternatingItem Or item.ItemType = ListItemType.Footer Then
                        Dim ddl_source As DropDownList = item.FindControl("ddl_source")
                        Select Case ddl_source.SelectedValue
                            Case 1, 4
                                Dim ddl_premiumtype As DropDownList = item.FindControl("ddl_premiumtype")
                                'ddl_premiumtype.Items.Clear()
                                If Not String.IsNullOrEmpty(category) Then
                                    build_premiumtype(category, ddl_premiumtype)
                                End If
                            Case 2, 3
                                Dim ddl_transfer As DropDownList = item.FindControl("ddl_transfer")
                                ddl_transfer.Items.Clear()
                                build_premium_transfer(ddl_transfer)
                        End Select
                    End If
                Next
        End Sub
    
    The page controls are updated fine, but the DDLs inside the DataList don't get updated. I don't get any errors and I think my logic is correct, but nothing happens.

    Can anyone see where I'm going wrong?

  2. #2
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Typical, isn't it....I've been going through this code for hours trying to work this out..The second I post it on the forum, I find out the problem.

    My build_premiumtype routine had a mistake in it that only occurred in this instance and hadn't occurred before...

    Fixed it now...

  3. #3
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    OK. It's still not 100% right.

    In the FooterTemplate of the Datalist I have the same dropdowns that allow you to add a New Premium to the list.

    When I change the category and the footer is visible, I need to relevant DDLs updated, but they're not changing. As you can see I include the FooterItem type in my If statement but nothing happens to the footer:-
    Code:
        For Each item As DataListItem In dlst_premiums.Items
                    If item.ItemType = ListItemType.Item Or item.ItemType = ListItemType.AlternatingItem Or item.ItemType = ListItemType.Footer Then
                        Dim ddl_source As DropDownList = item.FindControl("ddl_source")
                        Select Case ddl_source.SelectedValue
                            Case 1, 4
                                Dim ddl_premiumtype As DropDownList = item.FindControl("ddl_premiumtype")
                                'ddl_premiumtype.Items.Clear()
                                If Not String.IsNullOrEmpty(category) Then
                                    build_premiumtype(category, ddl_premiumtype)
                                End If
                            Case 2, 3
                                Dim ddl_transfer As DropDownList = item.FindControl("ddl_transfer")
                                ddl_transfer.Items.Clear()
                                build_premium_transfer(ddl_transfer)
                        End Select
                    End If
                Next
        End Sub
    
    Does the footer not get included in DataList.Items collection?

+ Reply to Thread

Similar Threads

  1. Control inside Accordion Content Template
    By richyrich in forum .NET Development
    Replies: 6
    Last Post: June 25th, 2008, 05:37 AM
  2. Database not updating
    By richyrich in forum .NET Development
    Replies: 5
    Last Post: June 3rd, 2008, 11:52 AM
  3. Accessing controls in the Footer of a datalist
    By richyrich in forum .NET Development
    Replies: 6
    Last Post: May 12th, 2008, 01:19 PM
  4. Finding Datalist Row on auto postback
    By richyrich in forum .NET Development
    Replies: 1
    Last Post: May 12th, 2008, 05:52 AM
  5. Help with Updating field
    By Rebelle in forum Microsoft Access
    Replies: 5
    Last Post: April 1st, 2008, 07:45 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO