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

How to: Filtering with a Server Mode

  • 2 minutes to read

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

In the sample, the sever mode is realized by binding ASPxGridLookup to the XpoDataSource component, whose ServerMode property is set to true. ASPxGridLookup’s incremental filtering can work in different modes (due to the ASPxGridLookup.IncrementalFilteringDelay and GridViewProperties.Settings.ShowFilterRow property settings); the “FirstName LastName” format is used to enter search strings and to represent the selected item’s value within the edit box (due to the ASPxGridLookup.TextFormatString property setting).

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;
        }
    }