Sunday, July 14, 2013

How to get top N Result from dataview or datatable in C#?

public static DataView SelectTopFrom(DataView dv, int rowCount)

{

DataTable dt = dv.ToTable();

DataTable dtn = dt.Clone();

for (int i = 0; i < rowCount; i++)

{

dtn.ImportRow(dt.Rows[i]);

}

DataView dvn = new DataView(dtn);

return dvn;

}

No comments:

Post a Comment