I'm trying to setup a RadComboBox control to use load on demand. In addition, the control is configured to use a template like so:
If I use something like:
MyControl.DataSource = MyCollection;
MyControl.DataBind();
The control populates fine. However, if I use something like the following, the RadComboBox shows an empty result. It sees that it has items thanks to the message, but the results themselves are empty.
Note that CurrencyCollection is simply a collection of custom Currency objects with a property of ISOCode representing its standard three letter representation.
<telerik:RadComboBox ID="CurrencyEdit" runat="server" Width="55px" DropDownWidth="300px" |
ShowToggleImage="true" ShowMoreResultsBox="true" EnableVirtualScrolling="true" |
Height="200px" DataValueField="ISOCode" DataTextField="ISOCode" EnableLoadOnDemand="True" |
OnItemsRequested="CurrencyEdit_ItemsRequested"> |
<HeaderTemplate> |
<table > |
<colgroup> |
<col width="60px" /> |
<col width="270px" /> |
</colgroup> |
<tr> |
<td> |
<asp:Literal ID="CurrencyISOCodeLabel" runat="server" meta:resourcekey="CurrencyISOCodeLabel" /></td> |
<td> |
<asp:Literal ID="CurrencyNameLabel" runat="server" meta:resourcekey="CurrencyNameLabel" /></td> |
</tr> |
</table> |
</HeaderTemplate> |
<ItemTemplate> |
<table style="border: solid 1px FFFF; font: menu; font-size: small; color: Black;"> |
<colgroup> |
<col width="60px" /> |
<col width="270px" /> |
</colgroup> |
<tr> |
<td> |
<%# DataBinder.Eval(Container.DataItem, "ISOCode") %> |
</td> |
<td> |
<%# DataBinder.Eval(Container.DataItem, "Name") %> |
</td> |
</tr> |
</table> |
</ItemTemplate> |
</telerik:RadComboBox> |
If I use something like:
MyControl.DataSource = MyCollection;
MyControl.DataBind();
The control populates fine. However, if I use something like the following, the RadComboBox shows an empty result. It sees that it has items thanks to the message, but the results themselves are empty.
protected void CurrencyEdit_ItemsRequested( object o, RadComboBoxItemsRequestedEventArgs e ) |
{ |
int itemsPerRequest = 10; |
int itemOffSet = e.NumberOfItems; |
int endOffset = itemOffSet + itemsPerRequest; |
CurrencyBinder binder = new CurrencyBinder(); |
CurrencyCollection currencies = binder.Find( e.Text ); |
if ( endOffset > currencies.Count ) |
endOffset = currencies.Count; |
e.EndOfItems = endOffset == currencies.Count; |
for ( int i = itemOffSet; i < endOffset; i++ ) |
{ |
Currency currency = currencies[i]; |
this.CurrencyEdit.Items.Add( new RadComboBoxItem( currency.ISOCode, currency.ISOCode ) ); |
} |
if ( currencies.Count > 0 ) |
{ |
e.Message = string.Format( "Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>" |
, endOffset |
, currencies.Count ); |
} |
else |
{ |
e.Message = "No matches"; |
} |
} |
Note that CurrencyCollection is simply a collection of custom Currency objects with a property of ISOCode representing its standard three letter representation.