Hi,
I have a RadComboBox that i would like to be populeated from a WCF Service, i see all of your examples and they all work just great, one thing i can figure out how to do is send in a param that has nothing to do with the dropdownlist other than what it is loading... So lets say i have 3 ComboBox's on the screen and each of them should use the same exact WebMethod from my service, the difference is they each send in a different param. The following is my ServiceMethods
As you can see this method needs to be called with the Type of Enum send in. I have seen from examples on the site that you can send in
EDIT:: I know i can easily take in a param of string and do reflection to create the Type, and that would be fine, i just need to the ability to let the webservice know which Enum to create and retrun...
I have a RadComboBox that i would like to be populeated from a WCF Service, i see all of your examples and they all work just great, one thing i can figure out how to do is send in a param that has nothing to do with the dropdownlist other than what it is loading... So lets say i have 3 ComboBox's on the screen and each of them should use the same exact WebMethod from my service, the difference is they each send in a different param. The following is my ServiceMethods
| [WebGet(ResponseFormat = WebMessageFormat.Xml)] |
| IEnumerable<RadComboBoxItemData> ICommonManager.EnumToList(Type t) |
| { |
| SortedList<string, int> myList = Common.GetEnumDataSource(t); |
| List<RadComboBoxItemData> items = new List<RadComboBoxItemData>(); |
| for (int i = 0; i < myList.Count; i++) |
| { |
| RadComboBoxItemData itemData = new RadComboBoxItemData(); |
| itemData.Text = myList.Keys[i]; |
| itemData.Value = myList.Values[i].ToString(); |
| items.Add(itemData); |
| } |
| return items; |
| } |
RadComboBoxContext
but that does not help as all that is, is an IDictionary. There are over 100 Enums that i try to do this with, it would be horrible if i had to create a WebMethod for each and everyone of these Enums.
Is there something i can set when i create this combobox(i create all of my dynamically with the ability to know if it's datasource comming from a webservice before the control is created) to send in to the webservice the type of enum i need it to return? Also all of my dropdowns have an 'EmptyMessage' set to something.
BTW: the reason i do that SortedList is so that i can return the Enum in Alpa order, here is that function for those that would like it.
| public static SortedList<string, Int32> GetEnumDataSource(Type enumType) |
| { |
| SortedList<string, Int32> returnCollection = new SortedList<string, Int32>(); |
| try |
| { |
| if (enumType.BaseType == typeof(Enum)) |
| { |
| string[] enumNames = Enum.GetNames(enumType); |
| foreach (string current in enumNames) |
| { |
| returnCollection.Add(current, Convert.ToInt32(Enum.Parse(enumType, current))); |
| } |
| } |
| return returnCollection; |
| } |
| catch (Exception ex) |
| { |
| return null; |
| } |
| } |
EDIT:: I know i can easily take in a param of string and do reflection to create the Type, and that would be fine, i just need to the ability to let the webservice know which Enum to create and retrun...