Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Thursday, October 05, 2006

.NET DataGrid with built-in filter functionality

.NET DataGrid with built-in filter functionality



With the DataGrid, Microsoft has provided a very mighty grid control which has some excellent features. With the possibility to easily add DataViews and customize visualization, the DataGrid is for sure one of the most important controls in the .NET Framework.

This component further extends the functionality of the DataGrid by adding filtering capabilities in an easy, automated and customizable way. The functionality goes beyond the requirements I had in my special case. But I thought it might be a good idea to make something sophisticated which can be used at various places.


Before reading this article, you should know the basics of working with the DataGrid. That's all you need to use this article. To better understand the technical background, you should also be familiar with the concepts of DataViews, RowFilter and DataGridTableStyles.

Using the code

There are three ways of using this component:

  • The FilterableDataGrid control can be used like any other control. It supports design time configuration. In order to display data, first set the DataSource property. Note that this property (unlike the one in the original DataGrid) takes only a DataView. As a second step a DataGridTableStyle must be added to the DataGrid which controls the visualization of data. Normally, the DataGrid provides default visualization, but in this case a real table style is needed. To make the use of this control easier, I have provided the DataGrid with some extra functionality to create the needed table styles and column styles as and when needed. The minimum code to get the control to work is:


.NET DataGrid with built-in filter functionality

Post a Comment