We help IT Professionals succeed at work.

Previous and Next buttons SQL and/or ASP.NET c#

Medium Priority
Last Modified: 2012-06-27

I need a little help with soemthing that i'm trying to do, I am a junior to SQL and .NET. I need a sql statement and if possible a asp.net (C#) code aswell that will allow me to switch between dynamic articles from the database.

I have two buttons, Previous and Next. If I am on article ID 12, by clicking Previous it should take me to articleID 11 and If I click next it should take me to article ID 13. So basically whatever article a user is on it should enable them to go back and forward reading the ID from the database/URL.

I need an SQL statement and ASP.NET (C#) code, so that I can get it to work in my project.  I have tried to have a go, but can't seem to get it right.

I hope you understand. Any help please ?
Watch Question

actually you need paging, have a look at following link, all you can do is, display all your article content in gridview and have paging with it, however you can do it programatically without gridview, but I don't have any script ready for that right now.


Formview gives you good control over paging.  PagerSettings gives you the flexibility of paging in the fashion that you are discussing.  Make sure that in your FormView Properties that you have AllowPaging = True.  

Please see Pictures for reference.  Hope this helps!  



Hello there, it's not paging.. thats not what I want to do. Say e.g. you have a list of articles on a page, when you click on an article, it should display it's item details on a different page. on that page I want a Next and Previous button, so rather the user goin back to a list of articles, they can navigate using the two buttons on it's details page.

hope this helps..
Unlock this solution and get a sample of our free trial.
(No credit card required)



I'm a junior, my knowledge is not that strong. Only know what i've been taught, although i'm still tryin it out. Yes that articles are stored in an SQL Server database with incremented numeric ID and storing the articles ID in the querystring.

Basically what you said is all correct. Do you know how I can be able to do this? I'm looking at storing the SQL in a stored procedure as it's more secure. any help?
Unlock this solution and get a sample of our free trial.
(No credit card required)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.