Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selected columns from DataTable

Tags:

c#

.net

datatable

How to get the Selected columns form the DataTable?
For e.g my BaseTable has three columns,
ColumnA,
ColumnB and
ColumnC.

Now as part of intermediate operations, I need to retrieve all the rows only from the ColumnA. Is there any predefined formula just like DataTable.Select?

like image 555
Krishna Avatar asked Sep 26 '11 22:09

Krishna


Video Answer


1 Answers

DataView.ToTable Method.

DataView view = new DataView(MyDataTable);
DataTable distinctValues = view.ToTable(true, "ColumnA");

Now you can select.

DataRow[] myRows = distinctValues.Select();
like image 177
CharithJ Avatar answered Oct 01 '22 11:10

CharithJ