Click here to Skip to main content
15,868,005 members

Response to: limit the records in dataset

Revision 2
C#
DataView dataView = new DataView(dataTable);
dataView.RowFilter = String.Format("EventDate > '{0}'", DateTime.Now);
dataView.Sort = "EventDate";
dataTable = dataView.ToTable();
while (dataTable.Rows.Count > _rowLimit)
{
    dataTable = dataTable.AsEnumerable().Skip(0).Take(50).CopyToDataTable();
}
return dataTable;


I forgot to say
You'll need namespace: System.Linq and System.Data
Posted 15-Nov-12 19:25pm by Ram424.
Tags: ,