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

  • SEARCH
  • Home
  • 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 6793745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:08:14+00:00 2026-05-26T18:08:14+00:00

This is the situation: I have an ASP.NET MVC 4 application. When I run

  • 0

This is the situation:

I have an ASP.NET MVC 4 application. When I run the application I go to a page and the Index – action on the controller takes a Guid as id – parameter. With that id I get a list of items from a database and put it into a ViewModel. This ViewModel is passed to a View which lists all of the items as an ActionLink (could be changed if necessary). When I click one of the items I want to get a list of other items, based on the id of the selected link, and show this new list right next to the first list.

But this is my question (and where I’ve been stuck for 2 days):
What is the best way to do this? Go to a new page or use a partial view. Because I have been trying a bit of both and clearly I must’ve done some things wrong because none seemed to work. I don’t need any AJAX-stuff or helpers like that, only a correct way to get this done… 🙂

Thanks in advance!

Update: the code that I already have

View

@foreach (var order in Model.Orders)
{
    <p>@Html.ActionLink(order.Name,
                        "OrderItems",
                        "OrdersController",
                        new { id = order.Id },
                        null)
    </p>
}

@if (Model.Detail != null)
{
    @Html.Partial("_OrderItemsByOrder", Model)
}

Controller

public ActionResult Index(Guid id)
{
    var orders = Services.GetOrders(id);
    var viewModel = new OrdersViewModel { Orders = orders };
    return View(viewModel);
}

public ActionResult OrderItems(Guid id, OrdersViewModel model)
{
    var orderItems = Services.GetOrderLines(id);
    var viewModel = new OrdersViewModel
    {
        Orders = model.Orders,
        Detail = new OrderDetailViewModel { OrderItems = orderItems }
    };
    return PartialView(viewModel);
}
  • 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-26T18:08:14+00:00Added an answer on May 26, 2026 at 6:08 pm

    There are several ways you could achieve a master/detail page like this, there really is no best way to do this. AJAX may be the most elegant and user friendly, but it’s by no means the “right” answer.

    Looking at the code you posted, the simplest thing you could do is have one action method and one view.

    public class OrdersViewModel
    {
        public IEnumerable<Order> Orders { get; set; }
        public OrderItems SelectedOrderItems { get; set; }
    }
    
    public ActionResult Orders(Guid id, Guid? orderId)
    {
        var model = new OrdersViewModel();
        model.Orders = Services.GetOrders(id);
    
        if (orderId != null)
        {
            model.SelectedOrderItems = Services.GetOrderLines(orderId);
        }
    
        return View(model);
    }
    

    The drawback with this rather basic approach is that you’ll have possibly 2 Guids dirtying up your Url and this example doesn’t verify that the orderId is actually owned by the (user?) Id – whatever the first Guid represents. You could handle this with a few lines of code though.

    A more elegant way of handling this, if you don’t mind your Url changing, is to stick with the second action method. I would hope you can determine the “owner” of an order detail from the detail itself, or in some way that wouldn’t require you to pass this into the action method. This helps ensure that your view only shows details from the right master.

    public ActionResult OrderDetails(Guid id /*the id of the order*/)
    {
        var orderLines = Services.GetOrderLines(id);
    
        var model = new OrdersViewModel();
        //ideally you could get to the "owner id" of the order from the order lines itself
        //depending on how your domain model is set up
        model.Orders = Services.GetOrders(orderLines.Order.OwnerId); 
        model.SelectedOrderItems = orderLines;
    
        return View("Orders", model); //render the same view as the Orders page if like
    }
    

    Your view as listed in your question can largely stay the same. Render the action links that represent all of the orders. Then render the order details if there is one in the model:

    @if (Model.SelectedOrderItems!= null)
    {
        /* markup here or a render partial call */
    }
    

    If you are rendering the order details on other pages, you’ll want to put your order details in a partial view so you don’t duplicate any of your markup. If it’s only rendered here, then there’s really no reason why you couldn’t have your markup right in this view.

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

Sidebar

Related Questions

I have a wizard in my asp.net MVC application which is built upon this
Here's the situation... Site 1) ASP.NET MVC application for customers to login, view and
I've have quite small asp.net MVC 2 application to maintain/extend. Currently it uses hand
I have an ASP.NET MVC application where I need to allow to customers configure
Have just started playing with ASP.NET MVC and have stumbled over the following situation.
I have an interesting situation where I need to deploy an ASP.NET MVC app
In an ASP.NET MVC application when using a custom Dependency Injection container (in this
I have an ASP.NET MVC 2 application in development that uses a web service
Say I have an application with the following structure. // ASP.NET MVC (Web Project)
I'm using Asp.Net MVC 2 and I have a situation where I'm building a

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.