how to get distinct record from DataView in C#

nik
nik
Member
40 Points
10 Posts

Hi,

how to get distinct record from DataView in C#?

 

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

Share:   fb twitter linkedin
Answers
NiceOne Team
NiceOne...
Admin
404 Points
67 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