SelectTopFrom method gets the top rows from dataview or datatable
Select top from for datatable and dataview
public static DataTable SelectTopFrom(DataTable dt, int rowCount)
{
DataTable dtn = dt.Clone();
for (int i = 0; i < rowCount; i++)
{
dtn.ImportRow(dt.Rows[i]);
}
return dtn;
}
public static DataView SelectTopFrom(DataView dv, int rowCount)
{
DataTable dt = CreateTable(dv);
DataTable dtn = dt.Clone();
for (int i = 0; i < rowCount; i++)
{
dtn.ImportRow(dt.Rows[i]);
}
DataView dvn = new DataView(dtn);
return dvn;
}
serkan sendur 821 Postaholic Banned Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.