?
Solved

how to get the first 10 records of a dataset

Posted on 2004-10-18
3
Medium Priority
?
343 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 600 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 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

770 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