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;
    }
1
Contributor
1
Reply
2
Views
9 Years
Discussion Span
Last Post by serkan sendur
0

I forgot to write "CreateTable" method above, you can look at it in the snipped named "Convert DataView To DataTable".
I think it is better to seperate these two snippets

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.