Solved

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

Posted on 2009-07-02
6
375 Views
Last Modified: 2012-06-27
Hi,

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 ?
0
Comment
Question by:Fezi
  • 2
  • 2
  • 2
6 Comments
 
LVL 31

Expert Comment

by:RiteshShah
ID: 24762507
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.

http://www.codeproject.com/KB/webforms/GridViewCustomPaging.aspx

http://programming.top54u.com/post/ASP-Net-2-0-Gridview-Paging-using-C-sharp.aspx
0
 
LVL 2

Expert Comment

by:Kyle_BCBSLA
ID: 24763083
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!  

-Kyle
PagerSettings.bmp
AllowPaging.bmp
0
 

Author Comment

by:Fezi
ID: 24763635
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..
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 31

Accepted Solution

by:
RiteshShah earned 350 total points
ID: 24763703
can't you hand programattically? I guess you are storing articles in your database, store it with incremented numeric ID, when you open one article, send it's ID to query string and store it in variable, once user click on "Next" get it's ID, may be it is 12 than get article which has 13 ID in database and show it on page.
0
 

Author Comment

by:Fezi
ID: 24763793
Hi,

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?
0
 
LVL 2

Assisted Solution

by:Kyle_BCBSLA
Kyle_BCBSLA earned 150 total points
ID: 24763812
Just as Rite suggested.  Either pass variables through your query string programatically or another route would be to use Session Variables to pass to the new page.  All you are doing is a redirect to another page and passing the SelectedIndex to the new page.  Using that index you can then connect it to your detailsview datasource on the new page where you can then use paging for each article up or down.  

I suggest you create a page that has a DetailsView connected to a datasource that accepts 1 parameter for a starting position.  Once you get that working, create a separate page(ListView) that lists all articles and set their value = ID of article.  This way when you click on the link you can pass the SelectedValue(the ID of the article) to your new page either through the query string on redirect or store the variable in Session and when the DetailsView page loads pick the ID up and display results.  

That would be my approach.  Good luck!  

-Kyle  
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

815 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

11 Experts available now in Live!

Get 1:1 Help Now