Solved

DataSet filter

Posted on 2008-10-01
4
286 Views
Last Modified: 2013-12-17
I have dataset populated with all records from student_table  who are Active and Inactive status.
I want to filter this dataset and create another one with all records which are inActive.
how can it be achieved .. thanks in advance
0
Comment
Question by:dotnet0824
4 Comments
 
LVL 5

Expert Comment

by:libin_v
ID: 22617823
You can use DataView.RowFilter
private void MakeDataView() 
{
   DataView dv = new DataView();
 
   dv.Table = DataSet1.Tables["Students"];
   dv.AllowDelete = true;
   dv.AllowEdit = true;
   dv.AllowNew = true;
   dv.RowFilter = "Status = 'Active'";
   dv.RowStateFilter = DataViewRowState.ModifiedCurrent;
   
   // Simple bind to a TextBox control
   Text1.DataBindings.Add("Text", dv, "StudentID");
}

Open in new window

0
 
LVL 3

Accepted Solution

by:
trunghieubkit earned 150 total points
ID: 22621367
Do you want to create new DataSet that contains all records with Inactive status from the original DataSet?
0
 
LVL 26

Assisted Solution

by:Anurag Thakur
Anurag Thakur earned 100 total points
ID: 22627007
if your requirement is to simply populate the active students already fetched in the previous table to another gridview then its quite simple

DataView dv = ds.Tables["student_table].DefaultView;
dv.RowFilter = "IsActive = true";

gvActiveStudents.DataSource = dv;
gvActiveStudents..DataBind();
0
 

Author Comment

by:dotnet0824
ID: 22628995
Raqi ur right.. Thats what i want. but can it be  a Dataset... DV is bound again . Can it be bound again to dataset. as I only know how to retrieve rows using Dataset
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display

856 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