aspnet-devexpress-dot-web-dot-aspxcombobox-46f609b6.md
Enables you to implement custom selection of the requested items by the filter conditions.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public event ListEditItemsRequestedByFilterConditionEventHandler ItemsRequestedByFilterCondition
Public Event ItemsRequestedByFilterCondition As ListEditItemsRequestedByFilterConditionEventHandler
The ItemsRequestedByFilterCondition event's data class is ListEditItemsRequestedByFilterConditionEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| BeginIndex | Gets an integer value that identifies the begin index of the editor’s items. |
| EndIndex | Gets an integer value that identifies the end index of the editor’s items. |
| Filter | Gets a string that represents a filter condition for the editor’s items. |
This event is a wrapper of the ComboBoxProperties.ItemsRequestedByFilterCondition event.
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();
}
<dxe:ASPxComboBox ID="ASPxComboBox1" runat="server"
EnableCallbackMode="true" CallbackPageSize="10"
IncrementalFilteringMode="Contains" ValueType="System.String" ValueField="OID"
OnItemsRequestedByFilterCondition="ASPxComboBox_OnItemsRequestedByFilterCondition_SQL"
OnItemRequestedByValue="ASPxComboBox_OnItemRequestedByValue_SQL"
TextFormatString="{0};{1}" TextField="From" Width="100%" DropDownWidth="610">
<Columns>
<dxe:ListBoxColumn FieldName="Subject" Width="300px"/>
<dxe:ListBoxColumn FieldName="From" Width="80px"/>
<dxe:ListBoxColumn FieldName="Sent"/>
</Columns>
</dxe:ASPxComboBox>
See Also