Amir Mirkamali

امیر میرکمالی

Get Top n Row From DataTable or DataView

public DataView GetTopDataViewRows(DataView source, int count)
{
    DataTable output = source.Table.Clone();
    for (int i = 0; i < count; i++)
    {
        if (i >= source.Count)
            break;
        output.ImportRow(source[i].Row);
    }
    return new DataView(output, source.RowFilter,     source.Sort, source.RowStateFilter);
}
Comments are closed