Setting the target and parent dropdown values from a DB when using CascadingDropDown
- by Ryan
Hi,
I have two dropdown lists with Cascading Dropdown, in the usual fashion:
<asp:DropDownList ID="DropDownListIndustry" runat="server"
DataSourceID="SqlDataSourceIndustries" DataTextField="name" DataValueField="industry_id" AppendDataBoundItems="
<asp:ListItem Text="(Please Select)" Value="-1" />
</asp:DropDownList>
<ajax:CascadingDropDown ID="CascadingDropDownIndustry" runat="server"
ParentControlID="DropDownListIndustry" TargetControlID="DropDownListSubIndustry"
ServicePath="AjaxDataProvider.asmx" ServiceMethod="GetSubIndustry"
Category="SubIndustry" />
<asp:DropDownList ID="DropDownListSubIndustry" runat="server"/>
No surprises there. However, I sometimes want to set the values of the parent and target from a DB (I want to default them, based on a code entered by the user; the whole thing is wrapped in an update panel). So if the user keys in ABC, I look up ABC in the DB and default the Parent DropDown to ID 10 and Child DropDown to ID 101.
However, this fails because the child has no items when the server side code runs (the web script method hasn't run, because the content of the parent dd wasn't changed on the client side)
Does anybody know how to work around this?
Thanks for any help!
Ryan