How to limit the number of rows after sorting the datatable vb.net/C#

0

How do I limit the amount of rows in a datagrid after DefaultView.Sort

Follow the code:

        da = New OleDbDataAdapter(MySQL, Conexao)
        dt = New DataTable("Pedidos")
        da.Fill(dt)
        dt.DefaultView.Sort = "Data Desc"
        Me.DataGridView1.DataSource = dt

I want to limit the number of lines after SORT, so the system has already ordered in the order I want.

    
asked by anonymous 15.07.2015 / 18:07

1 answer

1

Try using Linq, probably as follows: dt.AsEnumerable().Take(10) .

    
16.07.2015 / 15:19