select rows with errors

How can I fill a datagrid with just the rows from a datatable where haserrors = true?  Also, how can I get a count of the rows that have errors in a datatable?
km1039Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

km1039Author Commented:
Without looping through the rows collection for the count.
0
tusharashahCommented:
You can display such records like following:

DataView DataView1 = new DataView( DataSet1.Tables[0] );
DataView1.RowFilter = "haserrors='true'";
// DataView1.Count should give you all such records..
DataGrid1.DataSource = DataView1;
DataGrid1.DataBind();

-tushar
0
mmarinovCommented:
Hi km1039,

i don't think so
you can use this

DataTable dt_copy = your_dataTable.Clone();
foreach ( DataRow dr in your_dataTable.Rows )
{
    if ( dr.HasErrors )
    {
        dt.Rows.Add ( dr.ItemArray );
    }
}


Regards!
B..M
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

km1039Author Commented:
that will work... thanks.
0
km1039Author Commented:
Nevermind, it didnt work.  

So the only way to do it is to loop through the rows?
0
tusharashahCommented:
If DataView1.Count dose not provide correct count then creat DataView like following:

DataView DataView1 = new DataView( DataSet1.Tables[0],"haserrors='true'","", System.Data.DataViewRowState.CurrentRows )

-tushar
0
km1039Author Commented:
Still no luck.  The "haserrors='true'" is the problem.  It has to be a column in the datatable.
0
tusharashahCommented:
Oh in that case.. the way --> The B..M

-tushar
0
km1039Author Commented:
Thanks mmarinov.
0
mmarinovCommented:
km1039,

No problem, you are welcome
sorry, again for using you question for different purposes

Regards!
B..M
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.