New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

ItemsRequested

The ItemsRequested event occurs when the EnabledLoadOnDemand property is True and the user types text into the input field or clicks on the drop-down toggle image when the list is empty.

Items added in the ItemsRequested event handler are cleared when the next ItemsRequested event fires. If you, however, use the ShowMoreResultsBox mechanism or Virtual Scrolling the items will not be cleared upon clicking the ShowMoreResultsBox arrow or scrolling down.

The ItemsRequested event handler receives two arguments:

  1. The RadComboBox that is loading items. This argument is of type object, but can be cast to the RadComboBox type.

  2. An EventArgs object. This object has a number of properties for handling the request for new items:

  • Text is the text in the input area of the combobox. This value can be used to filter the items that are added.

  • Value is the value of the currently selected item.

  • Message is the message that appears in the ShowMoreResults box. This is only used when the ShowMoreResultsBox property is True.

  • NumberOfItems is the number of items that have been added by all previous calls to the ItemsRequested event handler when the ShowMoreResultsBox property is True.

  • EndOfItems is boolean property indicating the end of the items.

Use the ItemsRequested event handler to dynamically create the requested items and add them to the Items collection of the combobox:

<telerik:RadComboBox
    ID="RadComboBox1"
    runat="server"
    EnableLoadOnDemand="True"
    OnItemsRequested="RadComboBox1_ItemsRequested">
</telerik:RadComboBox>

protected void RadComboBox1_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
{
    RadComboBox combo = sender as RadComboBox;
    combo.Items.Add(new RadComboBoxItem("Item1", "1"));
    combo.Items.Add(new RadComboBoxItem("Item2", "2"));
    combo.Items.Add(new RadComboBoxItem("Item3", "3"));
}


Protected Sub RadComboBox1_ItemsRequested(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs)
    Dim combo As RadComboBox = TryCast(sender, RadComboBox)
    combo.Items.Add(New RadComboBoxItem("Item1", "1"))
    combo.Items.Add(New RadComboBoxItem("Item2", "2"))
    combo.Items.Add(New RadComboBoxItem("Item3", "3"))
End Sub

See Also

In this article