Tuesday, March 2, 2010

Find distinct values from a datatable / dataset

To filter the datatable based on the distinct value of a column, use the below code
dataSet.Tables(0).DefaultView.ToTable(true,"ColumnName") ;
or  dataTable.DefaultView.ToTable(true,"ColumnName") ;
where ColumnName is the name of the column whose distinct value is to be found.