I need to select 5 most recent rows from cached Dataview object, is there any way to do that?
I\'ve tried but Indexer DataColumn is empty. :
public
I encountered the same sample above in this article, but the last post says the provided code doesn't work.
However, this article has a solution that does work, so here's the code you could use:
public static DataView getLatestFourActive() {
DataTable productDataTable = getAll().ToTable();
DataTable cloneDataTable = productDataTable.Clone();
for (int i = 0; i < 4; i++) {
cloneDataTable.ImportRow(productDataTable.Rows[i]);
}
return new DataView(cloneDataTable);
}
getALL().Take(5);