Solved

how to get the first 10 records of a dataset

Posted on 2004-10-18
3
334 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

21 Experts available now in Live!

Get 1:1 Help Now