Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to get the first 10 records of a dataset

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

604 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