Using Cascading DropDown
-
I'm using a cascading dropdownlist using three tables. the code below works fine if my primary keys are numeric(integer) but my business rules want the primary keys to be alphernumeric(string). [WebMethod] public CascadingDropDownNameValue[] GetColors(string knownCategoryValues, string category) { StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); int colorId; if (!kv.ContainsKey("Model") || !Int32.TryParse(kv["Model"],out colorId)) { return null; } dsModelColorsTableAdapters.ModelColorsTableAdapter adapter = new dsModelColorsTableAdapters.ModelColorsTableAdapter(); dsModelColors.ModelColorsDataTable colors = adapter.GetColorsByModelId(colorId); List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); foreach (DataRow dr in colors) { values.Add(new CascadingDropDownNameValue((string)dr["ColorName"], dr["ColorID"].ToString())); } return values.ToArray(); } How do I use my string primary key using the above code? Please help an ajax technology adict.
ML Lingwati
-
I'm using a cascading dropdownlist using three tables. the code below works fine if my primary keys are numeric(integer) but my business rules want the primary keys to be alphernumeric(string). [WebMethod] public CascadingDropDownNameValue[] GetColors(string knownCategoryValues, string category) { StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); int colorId; if (!kv.ContainsKey("Model") || !Int32.TryParse(kv["Model"],out colorId)) { return null; } dsModelColorsTableAdapters.ModelColorsTableAdapter adapter = new dsModelColorsTableAdapters.ModelColorsTableAdapter(); dsModelColors.ModelColorsDataTable colors = adapter.GetColorsByModelId(colorId); List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); foreach (DataRow dr in colors) { values.Add(new CascadingDropDownNameValue((string)dr["ColorName"], dr["ColorID"].ToString())); } return values.ToArray(); } How do I use my string primary key using the above code? Please help an ajax technology adict.
ML Lingwati
You are aware that we have both 'Web Development' and 'ASP.NET' Forums?
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”