Skip to main content
A newer version of this page is available. .
Tab

ComboBoxProperties.ItemRequestedByValue Event

Handle this event to implement retrieval of an item by its value.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll

Declaration

public event ListEditItemRequestedByValueEventHandler ItemRequestedByValue

Event Data

The ItemRequestedByValue event's data class is ListEditItemRequestedByValueEventArgs. The following properties provide information specific to this event:

Property Description
Text Gets a string representing text of an item (entered or selected on the client side).
Value Gets an object that is the requested item’s value.

Remarks

The combo box provides you with the capability to manually populate a dropdown list with the required items. To implement this mode, it is necessary to handle both the ComboBoxProperties.ItemsRequestedByFilterCondition and ItemRequestedByValue events.

The ItemRequestedByValue event is raised when a combo box editor needs to obtain an item specified by its value from a data source. This event is usually raised when the server loads postback data (e.g., when filtering or validating data).

In the ItemRequestedByValue event handler, bind the combo box editor to a collection containing an item with the specified value. The processed item value can be accessed by the event argument ListEditItemRequestedByValueEventArgs.Value property. For more information, see the Dynamic List Population (Filtering Large Data Sources) help topic.

The ItemRequestedByValue event can be raised with the e.Value = null when nothing is explicitly selected/confirmed and the current editor’s Value is null.

When the entered filter does not return any results, the following scenarios are possible:

  • If the filter is explicitly confirmed, the e.Value should be equal to this filter;
  • If not, the combo box is bound to an empty collection.

The ComboBoxProperties.ValueType property is primarily intended for items, while the ASPxComboBox.Value property can be null. This situation is for scenarios when users specifically add an item whose Value property is null in order to explicitly select this item within the combo box when its Value is null.

Note

The ItemRequestedByValue event synchronizes its settings with the editor’s ASPxComboBox.ItemRequestedByValue event.

Example

The following section of the Filtering Large Data Source online demo illustrates how the ASPxComboBox.ItemsRequestedByFilterCondition and ASPxComboBox.ItemRequestedByValue events of the ASPxComboBox editor can be handled to filter the editor’s data source containing a large number of records.

Note

To work properly, both the ItemsRequestedByFilterCondition and ItemRequestedByValue events should be handled.

protected void ASPxComboBox_OnItemsRequestedByFilterCondition_SQL(object source, 
ListEditItemsRequestedByFilterConditionEventArgs e) {
         ASPxComboBox comboBox = (ASPxComboBox)source;
         SqlDataSource1.SelectCommand = @"SELECT OID, [From], Sent, Subject 
             FROM (select OID, [From], Sent, Subject, row_number() over(order by t.Sent) as [rn] 
             from dbo.ServerSideGridTest as t WHERE ((t.Subject LIKE @filter) OR (t.[From] 
              LIKE @filter))) as st where st.[rn] between @startIndex and @endIndex";
         SqlDataSource1.SelectParameters.Clear();
         SqlDataSource1.SelectParameters.Add("filter", TypeCode.String, string.Format("%{0}%", e.Filter));
         SqlDataSource1.SelectParameters.Add("startIndex", TypeCode.Int64, (e.BeginIndex + 1).ToString());
         SqlDataSource1.SelectParameters.Add("endIndex", TypeCode.Int64, (e.EndIndex + 1).ToString());
         comboBox.DataSource = SqlDataSource1;
         comboBox.DataBind();
}

protected void ASPxComboBox_OnItemRequestedByValue_SQL(object source, 
ListEditItemRequestedByValueEventArgs e) {
    ASPxComboBox comboBox = (ASPxComboBox)source;
    SqlDataSource1.SelectCommand = @"SELECT OID, Subject, [From], Sent 
        FROM dbo.ServerSideGridTest WHERE (OID = @OID) ORDER BY Sent";
    SqlDataSource1.SelectParameters.Add("OID", TypeCode.Int64, e.Value.ToString());
    ...
    comboBox.DataSource = SqlDataSource1;
    comboBox.DataBind();
}
See Also