how to get distinct record from DataView in C#

nik
nik
Member
166 Points
6 Posts

Hi,

how to get distinct record from DataView in C#?

 

Views: 9345
Total Answered: 1
Total Marked As Answer: 1
Posted On: 26-Jan-2015 01:54

Share:   fb twitter linkedin
Answers
NiceOne Team
NiceOne...
Editor
1382 Points
14 Posts
         

Hi Nik,

Suppose you have data table with columns - Country,State,City.

And you want to distinct State then following code will help you:

DataTable tempDataTable = new DataTable ();  DataTable tempDataTableDistinct = new DataTable ();  DataView tempDataView = new DataView (tempDataTable); tempDataTableDistinct = tempDataView.ToTable( true , "ColumnName" );

The tempDataTableDistinct will contains the distinct State.

 

Posted On: 26-Jan-2015 02:06
 Log In to Chat