Solved

how to get the first 10 records of a dataset

Posted on 2004-10-18
3
336 Views
Last Modified: 2006-11-17
I have a dataset of XML that gets exposed to my app with 50+ records.

How can I get the first 10 records. Note the dataset comes to me from another app, so I dont have any thing to do with how the dataset is filled to begin with.


Thanks for you help!
0
Comment
Question by:jrmcdona
3 Comments
 
LVL 28

Accepted Solution

by:
mmarinov earned 150 total points
ID: 12341702
Hi jrmcdona,

DataTable objDT = oldDS.Tables[0].Clone(); //this clone the structure of the old table , but not the data

for(int index=0; index < 9; index++ )
    {
        objDT.Rows.Add ( oldDS.Tables[0].Rows[index].ItemArray );
    }

so the new datatable contains only the first 10 records of the Dataset

B..M
0
 
LVL 18

Assisted Solution

by:tusharashah
tusharashah earned 100 total points
ID: 12341706
Not a straight solution but you can do something like following to remove all the data accept 1st 10 Rows...

for(int i=10;i< ds.Tables[0].Rows.Count; i++ )
{
      ds.Tables[0].Rows.RemoveAt(i);
}



OR

you can access the Table rows simply like ds.Tables[0].Rows[n] //where n is row number

-tushar
0
 

Author Comment

by:jrmcdona
ID: 12341912
Thats great! I am trying very hard to figure out some custom paging solution for my datagrid. I have to make it numeric (Page: 1 2 3 4...) and the PagerStyle-Visible has to be False so that I can display the paging in a label along with some other stuff. For the life me I can figure out how to do this. Especially without using SQL Server or a stored procedure. Most example use previous/next buttons which i dont want either!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Why don't I see this table in EDMX file? 2 23
Error on Add method 1 37
ASP.net Run 3 sliders vertically as opposed to horizontally 9 18
SQL Exceptions 3 36
Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now