none
How to select top 10 rows from dataview / Dataset RRS feed

  • Question

  • hey Here is problem def

    i m merging 3 table of dataset into one table & for sorting i have assigned merged data to Dataview 'dv'


    dv = Updates.Tables[0].DefaultView;
    dv.Sort = "UpdateDateTime";

    then i have applied sorting by "UpdateDateTime"

    Now this dataview should contain 100 records..

    Do you have any idea how to select only top 10 sorted results from dataview ?



    • Moved by VMazurModerator Monday, April 5, 2010 10:37 AM (From:ADO.NET Data Providers)
    Tuesday, April 29, 2008 11:19 AM

Answers

  • Hi,

     

    Code Snippet

    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;
    }

     

     

     

    Original Post

     

    HTH,
    Suprotim Agarwal

     

     

    Tuesday, April 29, 2008 11:27 AM

All replies