Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

select rows with errors

Posted on 2004-10-26
11
Medium Priority
?
230 Views
Last Modified: 2006-11-17
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?
0
Comment
Question by:km1039
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
11 Comments
 

Author Comment

by:km1039
ID: 12415114
Without looping through the rows collection for the count.
0
 
LVL 18

Expert Comment

by:tusharashah
ID: 12415234
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
 
LVL 28

Accepted Solution

by:
mmarinov earned 500 total points
ID: 12415241
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:km1039
ID: 12415242
that will work... thanks.
0
 

Author Comment

by:km1039
ID: 12415275
Nevermind, it didnt work.  

So the only way to do it is to loop through the rows?
0
 
LVL 18

Expert Comment

by:tusharashah
ID: 12415293
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
 

Author Comment

by:km1039
ID: 12415401
Still no luck.  The "haserrors='true'" is the problem.  It has to be a column in the datatable.
0
 
LVL 18

Expert Comment

by:tusharashah
ID: 12415436
Oh in that case.. the way --> The B..M

-tushar
0
 

Author Comment

by:km1039
ID: 12415580
Thanks mmarinov.
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 12415614
km1039,

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

Regards!
B..M
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question