multi-column RadComboBox via a web method.
ASPX
<telerik:RadComboBox runat="server" ID="RadComboBox1" Width="200px" MarkFirstMatch="true" EnableLoadOnDemand="true" HighlightTemplatedItems="true" DroDownCssClass="exampleRadComboBox"> <HeaderTemplate> <tr> <th class="col1">Category Name</th> <%-- <th class="col2">Some other column</th>--%> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td class="col1"> <%# DataBinder.Eval(Container.DataItem, "Category_Name") %></td> <%-- <td class="col2"> <%# DataBinder.Eval(Container.DataItem, "Some_Other_Col") %></td>--%> </tr> </ItemTemplate> <WebServiceSettings Method="GetCat" Path="Default.aspx" /></telerik:RadComboBox>
Code Behind
[WebMethod] public static RadComboBoxData GetCatType(RadComboBoxContext context) { var x = "[{'CoachingSessionActivityCategoryID':0,'CoachingSessionActivityTypeID':1000005,'Category_Name':'Skills Conditioning','TeamID':0,'ClubID':1,'Type_Name':'Skills Con - Small Sided Games (Attack)'}]"; var data = JsonConvert.DeserializeObject<DataTable>(x); RadComboBoxData comboData = new RadComboBoxData(); var itemOffset = context.NumberOfItems; var endOffset = Math.Min(itemOffset + 10, data.Rows.Count); comboData.EndOfItems = endOffset == data.Rows.Count; List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(endOffset - itemOffset); for (int i = itemOffset; i < endOffset; i++) { RadComboBoxItemData itemData = new RadComboBoxItemData(); itemData.Text = data.Rows[i]["Category_Name"].ToString(); itemData.Value = data.Rows[i]["Category_Name"].ToString(); result.Add(itemData); } comboData.Items = result.ToArray(); return comboData; }
The question is:
1) How do I bind the combobox to the web method?
2) How do I bind multiple columns to the combo box with the web method?