• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 679
  • Last Modified:

DataGridView / DataTable - Sort by row errors

Hi All,

I have a DataTable that I have bound to a DataGridView.  In the DataTable there are several rows where I have manually set the DataRow.RowError property.  

How do I sort the DataTable (or a related DataView), so that the rows with errors are displayed first?

Cheers

Nick
0
nickhoggard
Asked:
nickhoggard
1 Solution
 
RamuncikasCommented:
If you set DataRow.RowError manually then I assume you are itterating through all of the rows and checking for some conditions. What I'd suggest here is:
 - add one extra column to your datatable (let's call it cError) of type Boolean
 - in the iteration process set DataRow("cError") = True along with DataRow.RowError setting
 - the set sorting and filtering in DataTable's Defaultview
 - Bind gridview to DataTable's Defaultview

HTH
R
0
 
nickhoggardAuthor Commented:
Thanks,

For a moment I was hoping that MS had an internal way of doing this, but that solution has done the job.

Cheers

Nick
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now