Ross Coded Classes

Programming tips with no rose colored glasses.

DataView RowFilter Performance

Avoid using the default System.Data.DataView constructor followed by setting the RowFilter property.  When you want to create a System.Data.DataView object and apply a RowFilter, use the DataView constructor that takes the rowFilter parameter.  This eliminates processesing of DataRowView objects that are later removed when the RowFilter property is set.  This is particularly apparent when the DataTable has many rows and the RowFilter eliminates most of them.
Note that you will need to specify Sort and DataRowViewState options to use this constructor.  The defaults are an empty string for Sort and DataViewRowState.CurrentRows for RowState.
DataView slowWay = new DataView(table);
slowWay.RowFilter = rowFilter;

DataView fastWay = new DataView(table,

1 thought

  1. Right here is the perfect website for anybody who hopes to find out about this topic.

    You understand so much its almost hard to argue with you (not that I actually will need to…HaHa).

    You certainly put a brand new spin on a topic which has been discussed for ages.
    Wonderful stuff, just great!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.