Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 653391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:22:37+00:00 2026-05-13T22:22:37+00:00

I think there is a simple answer to this, but for some reason I

  • 0

I think there is a simple answer to this, but for some reason I am hitting a writers block today. I have an app which people can search (like any app 🙂 ) and generate a list view. From that list view, you can view details, which will take you to a details view. No JS, just another page. But, what I would like to do is to have a back/next button within the details view so that you can parse the result set without having to go back to the list and then select the next record.

I have had two ideas on accomplishing this. Idea 1) Have a next/previous record field in my custom class. However, this wouldn’t work as the search query will not necessarily return consecutive results and I would have to query the DB each time to get those next/prev listings. Idea 2) Have a list of IDs or some custom object passed in the view state for each detials view corresponding to the search results. On this one, I am not sure of the ‘overhead’ associated with this method.

Any suggestions from the SO community?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:22:38+00:00Added an answer on May 13, 2026 at 10:22 pm

    Construct the link that opens the details view so that it has next and previous parameters that contain a list of the previous/following elements as well as the id of the current element. Probably easiest to do if you iterate through the list model data by index rather than using foreach — that way you just reference the previous/next element relative to the current element when finding their ids. Make sure to handle the first and last elements correctly.

    In your controller action the next/previous parameters should be nullable — if you don’t get there from the list, you don’t render the next/previous buttons. You could “post” the details view action and put the extra parameters in the form rather than the URL so the user can still bookmark the url. Note that this has it’s own issues though with regards to the browser’s back/forward button and refreshing.

    <% for (int i = 0, len = Model.Count(); i < len; ++i)
       {
          Foo model = Model.ElementAt(i);
          string prev  = i == 0 ? null : string.Join( ",", Model.Take(i).Select( m => m.ID.ToString() ).ToArray() );
          string next = i == (len - 1) ? null : string.Join( ",", Model.Skip(i).Select( m => m.ID.ToString() ).ToArray() )
     %>
       <% using (Html.BeginForm("Details","Bar", new { id = model.ID } )) { %>
            <%= Html.AntiForgeryToken() %>
            <%= Html.Hidden( "Prev", prev ) %>
            <%= Html.Hidden( "Next", next ) %>
            <input type="submit" value="Details" />
       <% } %>
    <% } %>
    

    I would probably also use some jQuery to change the input button to a link that submits the enclosing form with a click event handler, but that’s just my preference for the UI.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is an accident and I don't think there's a solution. But I'm asking
There is another recent Project Euler question but I think this is a bit
All, This question probably has a very simple answer - something I'm overlooking. But
I think in this case there is no need to declare a public constructor
I think I understand unit testing. But I was wondering: is there a way
I posted this on GAE for Java group, but I hope to get some
I realize this question is very likely to have been asked before, but I've
I had asked this question before, but I got no correct answer. So, this
I think there are a lot of people out there unaware of RFC's (Request
I think there is a wealth of natural language data associated with sites like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.