Solved

how to get the first 10 records of a dataset

Posted on 2004-10-18
3
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 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