views:

222

answers:

2

Hi!

I'm currently facing the problem, that I import an Excel file to a DataGrid. This works pretty fine, but after importing the table, I need to know how many rows are invalid.

I have applied several validation rules for the different datatypes, and I have an icon in the row header, that shows up if the row is invalid. But since I have more that 10.000 rows in the grid, I don't want scroll all the way through it to find the errors.

Any ideas, how to determine the count of invalid rows (and then maybe bind that to a textbox)?

Thx

A: 

Well, if you're using WPF in the manner that I would term to be "correctly", you shouldn't care about the DataGrid itself in order to get the results you want. You could just run a simple LINQ expression off of the data that the grid is bound to coming up with the count of invalid rows.

Dave Markle
A: 

That is indeed the solution to one part of the problem. But the user can also edit the values, so they are validated before they are written back to the datatable...

Your approach would cover the import (null values etc.). I think that I have to write an own class, that iterates through the rows and their rowerrors...

SuperFloh1234