Skip to main content

How to: Filter in Server Mode

  • 2 minutes to read

This example illustrates how ASPxGridLookup’s incremental filtering can be utilized efficiently in server mode when the editor is bound to a large data source (over 20,000 records).

In the example, ASPxGridLookup is bound to an XpoDataSource component whose ServerMode property is set to true, which enables server mode for the control.

ASPxGridLookup’s filtering works in the following modes:

The “FirstName LastName” format (TextFormatString = "{0} {1}") is used to enter search strings and display the selected item’s value within the edit box.

gridlookup-filtering.png

    protected void Page_Load(object sender, EventArgs e) {
        if (!IsCallback && !IsPostBack)
            RadioButtonList.SelectedIndex = 0;
        UpdateFilteringMode();
        GridLookup.GridView.Width = 370;
    }

    protected void Page_Init(object sender, EventArgs e) {
        Session session = XpoHelper.GetNewSession();
        XpoDataSource.Session = session;
    }

    protected void UpdateFilteringMode() {
        switch (RadioButtonList.SelectedItem.Value.ToString()) {
            case "StartsWith":
                GridLookup.IncrementalFilteringMode = IncrementalFilteringMode.StartsWith;
                GridLookup.GridViewProperties.Settings.ShowFilterRow = false;
                GridLookupCaptionLabel.Text = "Start typing to invoke filtering:";
                break;
            case "Contains":
                GridLookup.IncrementalFilteringMode = IncrementalFilteringMode.Contains;
                GridLookup.GridViewProperties.Settings.ShowFilterRow = false;
                GridLookupCaptionLabel.Text = "Start typing to invoke filtering:";
                break;
            case "Filter Row":
                GridLookup.IncrementalFilteringMode = IncrementalFilteringMode.None;
                GridLookup.GridViewProperties.Settings.ShowFilterRow = true;
                GridLookupCaptionLabel.Text = "Type within the grid filter row to start filtering:";
                break;
        }
    }