?
Solved

Record Navigation....

Posted on 2004-11-16
11
Medium Priority
?
290 Views
Last Modified: 2010-07-27
Hi all,

My grid displays several rows of data. Each row has a link, which when clicked, displays the detail page for that row. What I want is to have a PREVIOUS and NEXT navigation on this detail page, thereby allowing the user to flick back and forth thru the records without having to go back to the master page.

When the link is clicked to jump to the detail page I am not sure how to increment the records from that particular ID.

I would appreciate any help on this,

regards,

KS
0
Comment
Question by:Ramesh Srinivas
  • 7
  • 4
11 Comments
 
LVL 28

Expert Comment

by:mmarinov
ID: 12592335
Hi saleek,

i think the scenario should be:
1. in the link of the list page you should include the id of the record
2. also you have to add to a session variable an array of these ids
3. on the detail page, when you have to id of the current record you can search through this array and find the previous/next id and get its data from database

Regards!
B..M
mmarinov
0
 
LVL 11

Author Comment

by:Ramesh Srinivas
ID: 12592457
Hi mmarinov,

I am already including the IDs in a hidden column in the grid.

How would I capture the entire list of IDs generated by the dataset? Should I loop through each datarow before binding and store in session var as array?

thanks,

KS
0
 
LVL 28

Accepted Solution

by:
mmarinov earned 300 total points
ID: 12592561
this is one way
another way i've though of is to keeps in a session just the current, previous and next id
this you can get from the itemcommand event before redirecting to the next page
and when you click on previous/next button in the details page by getting the data you can add 2 additional parameters which will be output type and will return the previous and next ids

B..M
mmarinov
0
Industry Leaders: 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!

 
LVL 11

Author Comment

by:Ramesh Srinivas
ID: 12592678
mmarinov,

Could you elaborate on your second idea a bit more please.

How can I navigate all records by just having the previous and next IDs?? I don't quite understand that one.

Thanks for your help,

KS
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 12592773
on your details page you have

details
<       >
where <> are links to the previous/next id, correct ?
so if you have the ids you can to the things

when you click on the link within the list page you pass and id to the current record so you can get the complete info. so i suggest you to get the id from previous and next row in the dataset
then you have these ids

the problem arise with the clicking on the <>, but ... when you get the info from database by the passed id, you can get and the previous and next ids for the passed ids and assign them to the <> links

B..M
mmarinov
0
 
LVL 11

Author Comment

by:Ramesh Srinivas
ID: 12592887
Okay, I will give it a go.

thx.
0
 
LVL 11

Author Comment

by:Ramesh Srinivas
ID: 12643344
If I am passing the ID from master page, and then fetching the record based on that ID - it will return 1 row - so to get the next and previous IDs I would have to query the database again, passing that same ID and then some how get it to return the row ID-1 and ID+1.

I am having difficulty understanding how this would work.

regards,

KS
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 12643364
you can query the database with a single storedprocedure
define 2 output parameters
perdorm you select statement to get details data
and after then perform select to get the previous and the next ID
in the code behind bind data to datagrid and use the 2 parameters to build the links

B..M
mmarinov
0
 
LVL 11

Author Comment

by:Ramesh Srinivas
ID: 12643578
Okay, I understand the mechanics of what you are saying now - thanks.
0
 
LVL 11

Author Comment

by:Ramesh Srinivas
ID: 12644503
I have made an SP to output next and previous:

CREATE PROCEDURE [SP_GetNextPreviousPress]

@ID integer,
@Next integer Output,
@Previous integer Output

AS

SELECT @next = MIN(MON_ID)
FROM TBL_Monitored
WHERE MON_ID > @ID

SELECT @previous = MAX(MON_ID)
FROM TBL_Monitored
WHERE MON_ID < @ID
GO


Now I am trying to get the next and previous IDs using a datareader, but seem to be getting the following error:

Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near 'SP_GetNextPreviousPress'.


My ASP.NET code is:

        Dim dr As SqlDataReader

        Dim myConn As New SqlConnection
        myConn = intMed.iMConn
        Dim Cmd As New SqlCommand("[SP_GetNextPreviousPress]", myConn)

        Dim IDParam = New SqlParameter("@ID", SqlDbType.Int)
        IDParam.value = tID
        IDParam.Direction = ParameterDirection.Input
        Cmd.Parameters.Add(IDParam)

        Dim NextID = New SqlParameter("@Next", SqlDbType.Int)
        NextID.Direction = ParameterDirection.Output
        Cmd.Parameters.Add(NextID)

        Dim PrevID = New SqlParameter("@Previous", SqlDbType.Int)
        PrevID.Direction = ParameterDirection.Output
        Cmd.Parameters.Add(PrevID)

        dr = Cmd.ExecuteReader()
        'Cmd.Dispose()

        While dr.Read()
            Session("NextID") = dr(0)
            Session("PrevID") = dr(1)
        End While


What am I doing wrong/not doing? thanks very much.

KS

0
 
LVL 11

Author Comment

by:Ramesh Srinivas
ID: 12644760
Never mind, got it!
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

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…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month15 days, 19 hours left to enroll

850 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