Question show some rows of a datatable in datagridview

pooya1072

Well-known member
Joined
Jul 5, 2012
Messages
84
Programming Experience
Beginner
hi
i have a datagridview in my form . a datatable (DataTable1) with 50 rows , is its Data Source . (dgv1.DataSource=DataTable1)
i want to show only 5 rows of the end of this datatable in datagriview.
what should i do ?
 
Hi,

You would typically do something like this when you fill your DataTable with your DataAdapter by limiting the rows returned from your DataBase Select statement. i.e:-

VB.NET:
SELECT TOP (5) dbo.Customers.*
FROM dbo.Customers

Hope that helps.

Cheers,

Ian
 
Back
Top