I have wired 2 dropdownlists to the cascadingdropdown controls. My page code looks like this:
1<asp:DropDownList ID="StateDropDownList" runat="server" />2<ajax:CascadingDropDown ID="StateDropDownListCascadingDropDown" runat="server" Enabled="True" Category="StateName"3 PromptText="Select a state" ServiceMethod="GetDropDownStates" ServicePath="~/Site_Services/Datasets.asmx"4 TargetControlID="StateDropDownList" />56<asp:DropDownList ID="CountyDropDownList" runat="server" />7<ajax:CascadingDropDown ID="CountyDropDownListCascadingDropDown" runat="server" Enabled="True" Category="County"8 PromptText="Select a county" ServiceMethod="GetDropDownCounties" ServicePath="~/Site_Services/Datasets.asmx"9 ParentControlID="StateDropDownList" TargetControlID="CountyDropDownList" />
I've simplified the second web method to try anything to get the 2nd dropdownlist to work and no matter what, it still doesn't work. Here is the simplified method:
1 [System.Web.Services.WebMethod]2 [System.Web.Script.Services.ScriptMethod]3public CascadingDropDownNameValue[] GetDropDownCounties(string knownCategoryValues,string category)4 {5 List<CascadingDropDownNameValue> values =new List<CascadingDropDownNameValue>();6 values.Add(new CascadingDropDownNameValue("Test","Test"));7return values.ToArray();8 }
Here's what is posted:
The server returns no response. Any ideas?
j_gaylord:
5List values =new List();
Are you referring a generic List<> collection?
I got an article on Cascading dropdownlist athttp://www.aspalliance.com/1183 . Check it
Thanks
Yes. The code didn't print out properly as the Code screen in the forums ommited my < and >. I updated the code above. You'd think that it would work regardless because no matter what the values are, a value is being added to the collection. However, that's not the case.
any ideas?
nudge
Two things I would check are:
1. The webservice is decorated with [System.Web.Script.Services.ScriptService] attribute.
2. The correct web.config file and the AjaxControlToolkit.dll binary.
Thanks
Both of them are correct. I already have one drop down working. Its just the second one who's parent is the first is not.
j_gaylord:
Both of them are correct. I already have one drop down working. Its just the second one who's parent is the first is not.
In such case, the second dropdown should also fill, as the method [GetDropDownCounties] you wrote has nothing to do with the parent dropdownvalue. I have tested your code and its working fine for me. You messed up something for sure.
Thanks
Thanks for the positive insight. Any further suggestions?
No comments:
Post a Comment