Paging Records on at a time.

S

SouthSpawn

Hello,

I have an asp.net application that will use a SQL Server DBMS for the
backend.
On my asp.net form. I have a next, previous, last and first buttons on my
form.
Basically, this application will allow the user to page through some data
one record at a time.

Let's say my SQL statement returns the following rows with ID's of (1, 3,
5, 9, 10).
What would be the best way that I can always retrieve the previousID and
nextID according to the rows my Select SQL statement returned?

Thanks,
Mark
 
G

Grant Merwitz

If your using a DataGrid, you can use the Inbuilt paging.
This will keep track of what the previous and next items are.

private void dg_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)

{

dg.CurrentPageIndex = e.NewPageIndex;

PopulateGrid(); //this would rebind the grid but the the CurrentPageIndex
set as above

}

Also ensure to set the AllowPaging attribute on your DataGrid to true,
and in your case, set the PageSize to 1

If your using a DataList, i don't believe it has InBuilt paging, and you'll
have to build a custom solution
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,265
Messages
2,571,071
Members
48,771
Latest member
ElysaD

Latest Threads

Top