CasdingDropDown
Hi
First to introduce my application, where I am using cascadingdropdown ajax control.
In my application, I have one Page, with update panels on it. Whenever user click on any menu button. I dynamically load respective usercontrol, according to current selected menu.
Usercontrols that I load, are actual controls where user interacts like login control, registration control etc etc.
On one such user control I am using cascadingdropdown ajax control. Where user can select items and then edit it by clicking on by clicking edit link button.
Problem is, whenever user select a value, and click on edit link button, it lose it selected value. in other terms viewstate information got lost.
I test same control on another test.aspx page. where I just put this control on the page. statically. Not a daynamic loading. on that page it is working good.
But with dynamic loading of usercontrol it is creating problem. I mentioned above. any Idea????? Please I am struggling with this problem since last 3 days. I am worried about it.
Regards,
Azam.
Brandon BaumPosted May 19, 2009, 11:33 AM
I'm not sure if I have a solution. But I am having trouble getting the CascadingDropDown to work as well. If anyone has solutions. I've checked on Asp.Net forums and tried all the suggestions there and still having nothing to show for it.
WebService Code and function:
[
WebService(Namespace = "http://tempuri.org/")][
WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.
ScriptService]public
class CascadeDropdownHandler : System.Web.Services.WebService{
[WebMethod] public CascadingDropDownNameValue[] GetCategories(string knownCategoryValues, string category){
//Get a source for the known category/value pairs.dsCategoriesTableAdapters.
CategoriesTableAdapter makeAdapter = new dsCategoriesTableAdapters.CategoriesTableAdapter(); dsCategories.CategoriesDataTable makes = makeAdapter.GetCategories(); List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); foreach (DataRow dr in makes){
string pCategory = (string)dr["cat_name"]; int pCatID = (int)dr["category_id"];values.Add(
new CascadingDropDownNameValue(pCategory, pCatID.ToString()));}
return values.ToArray();}
[
WebMethod] public CascadingDropDownNameValue[] GetSubCategories(string knownSubCategoryValues, string category){
StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownSubCategoryValues); int pCatID; if (!kv.ContainsKey("categoryList") || !Int32.TryParse(kv["categoryList"], out pCatID)){
return null;}
dsSubCategoriesTableAdapters.
SubCategoriesTableAdapter subAdapter = new dsSubCategoriesTableAdapters.SubCategoriesTableAdapter(); dsSubCategories.SubCategoriesDataTable subcats = subAdapter.GetDataByCategory(pCatID); List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); foreach (DataRow dr in subcats){
values.Add(
new CascadingDropDownNameValue((string)dr["sub_cat_name"], dr["sub_categoryID"].ToString()));}
return values.ToArray();}
}
As far as my code goes for the objects I have the following:
<
ajaxToolkit:CascadingDropDown ID="catList_CascadingDropDown" runat="server" TargetControlID="catList" PromptText="Select Category" Category="categoryList" LoadingText="Please wait..." ServicePath="~/CascadeDropdownHandler.asmx" ServiceMethod="GetCategories"> ajaxToolkit:CascadingDropDown> <ajaxToolkit:CascadingDropDown ID="subCatList_CascadingDropDown" runat="server" TargetControlID="subCatList" ParentControlID="catList" PromptText="Select Sub-Category" Category="Subcategory" LoadingText="Please wait..." ServicePath="~/CascadeDropDownHandler.asmx" ServiceMethod="GetSubCategories"> ajaxToolkit:CascadingDropDown>Anyone have any ideas why this wouldn't work? The first one does work, but the second one comes up with Error Method 500. I've tried adding a web.extension item in the web.config to expand the limit of jsonSerialization length, changing the first drop down autopostback from true to false and vice versa. Not sure what the hang up is.