Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > How to get top 10 rows of data in a datagrid
 

How to get top 10 rows of data in a datagrid

Hi all,
There are 20 rows that I am getting from database and I need to display the data in two datagrids.Please can any one help me out with a sample code in C#.I tried using dataview but no luck.
  • Moved byVMazurMVPFriday, July 17, 2009 10:42 AM (From:ADO.NET Data Providers)
  •  
kooldude51  Thursday, July 16, 2009 2:52 AM
Please explain which criteria you want to use to determine which rows should go in the first grid and which in the second grid.
BinaryCoder  Thursday, July 16, 2009 10:21 PM
Hi,

Based on my understanding, you retrieve 20 rows from a database table and would like to show the first 10 rows in a DataGridView and the left 10 rows in the other DataGridView. If I'm off base, please feel free to let me know.

You canretrieve the 20 rows from database and fill them into a DataTable. Then add the latter 10 data rows in the DataTable into another DataTable and remove those data rows from the first DataTable. Bind one DataGridView to the first DataTable and bind the other DataGridView to the second DataTable by setting the DataSource property of the DataGridView to the DataTable).
Please remember to mark the replies as answers if they help and unmark them if they provide no help. end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Linda Liu  Tuesday, July 21, 2009 7:21 AM

You can use google to search for other answers

Custom Search

More Threads

• c# : How can i add these numbers on this area?
• delete from datagridview
• linked listboxes
• cell validating in a datagridview
• how to verify empty datagrid?
• BindingNavigatorAddNewItem and checkbox lookups?
• User control with datagridview
• Custom Object & DataGridView & Binding to the Properties of Property
• DataGridView add new row problem need help.
• dataset HasChanges