What is the best practice you would suggest when filtering a fairly large data set (~400K records) in the grid? This is my current scenario:
1. I have a grid, a couple of search fields, and a search button. Standard paging is enabled in the grid.
2. The grid has a NeedDataSource event handler that runs a query against my database and then populates the grid with the results from the query. This query selects all records from the appropriate database tables. The DataSource property of the grid is set to this query.
3. The Click event handler of the search button checks if any of the search fields has text in it. If so, the FilterExpression of the grid is built with the proper criteria. If no search fields have any text, then the FilterExpression will remain empty and all records are returned. At the end, the Click event handler calls Rebind() on the grid, which in turn will call the NeedDataSource event handler.
4. The Page Index Changed event handler updates the current page index and calls Rebind() on the grid.
The filtering and paging work but it's rather slow (~20 seconds). Is this the correct approach for this problem? I'm worried that I'm getting all database records every single time and my application will be used in a low-bandwidth scenario. Or would it be better to change my query in the NeedDataSource event handler directly so that the grid DataSource property is only set to what is actually specified in the search criteria rather than use the FilterExpression?
1. I have a grid, a couple of search fields, and a search button. Standard paging is enabled in the grid.
2. The grid has a NeedDataSource event handler that runs a query against my database and then populates the grid with the results from the query. This query selects all records from the appropriate database tables. The DataSource property of the grid is set to this query.
3. The Click event handler of the search button checks if any of the search fields has text in it. If so, the FilterExpression of the grid is built with the proper criteria. If no search fields have any text, then the FilterExpression will remain empty and all records are returned. At the end, the Click event handler calls Rebind() on the grid, which in turn will call the NeedDataSource event handler.
4. The Page Index Changed event handler updates the current page index and calls Rebind() on the grid.
The filtering and paging work but it's rather slow (~20 seconds). Is this the correct approach for this problem? I'm worried that I'm getting all database records every single time and my application will be used in a low-bandwidth scenario. Or would it be better to change my query in the NeedDataSource event handler directly so that the grid DataSource property is only set to what is actually specified in the search criteria rather than use the FilterExpression?