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?
richyrich, July 9th, 2008 11:44 AM
Bookmarks