Select Distinct and obtain all row of it

Just clarifying things in a more clear way so it will be easy for Beginner level users :slight_smile:

dataTable.DefaultView.ToTable(true, “Column1”)

or

DataView view = new DataView(table);
DataTable distinct_Values = view.ToTable(true, “Column1”, “Column2” …);

Where:

  • First parameter in ToTable() is a boolean which indicates whether you want distinct rows or not.

  • Second parameter in the ToTable() is the column name based on which we have to select distinct rows.

Only these columns will be in the returned datatable.

Regards…!!
Aksh

8 Likes