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 5963511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:15:58+00:00 2026-05-22T19:15:58+00:00

I am using shared editor templates to render nested collections in my view with

  • 0

I am using shared editor templates to render nested collections in my view with the ‘EditorFor’ HTML helper, similar to the following. I’m not in love with all of these nested partial views but doing it this way names the elements appropriately so that they post back to my controller in the ViewModel without an issue.

How would I sort the order at the most resolute level of the nest? In this case, how would I get “Budget.vbhtml” to display in Year order (descending)?

Thanks in advance!

Top-level view (Organization.vbhtml):

<div id="budgets">
     @Html.EditorFor(Function(org) org.OrganizationBudgets))
</div>

OrganizationBudget.vbhtml:

@ModelType CharityMVC.OrganizationBudget
@Html.EditorFor(Function(ob) ob.Budget)

Budget.vbhtml:

@ModelType CharityMVC.Budget
@Model.Year @Html.EditorFor(Function(b) b.Amount)

UPDATE:

It sounds like I should be doing this in my controller when I populate my Model object, but how do I sort the children or children-of-children in a linq query? This is my current code:

Function Edit(ByVal id As Integer) As ActionResult
    Dim o As Organization
    Dim ovm As OrganizationViewModel

    'Load the organization from the database
    o = (From org In _db.Organizations _
        Where org.Id = id _
        Select org).FirstOrDefault()

    'Map it to the ViewModel
    ovm = AutoMapper.Mapper.Map(Of Organization, OrganizationViewModel)(o)

    Return View(ovm)

End Function
  • 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-22T19:15:59+00:00Added an answer on May 22, 2026 at 7:15 pm

    My best answer so far:

    Multple LINQ queries populating the child properties like so:

    Function Edit(ByVal id As Integer) As ActionResult
        Dim o As Organization
        Dim ovm As OrganizationViewModel
    
        'Load the organization from the database
        o = (From org In _db.Organizations _
            Where org.Id = id _
            Select org).FirstOrDefault()
    
        o.OrganizationBudgets = (From ob In _db.OrganizationBudgets _
                                 Where ob.OrganizationId = o.Id _
                                 Order By ob.Budget.Year Descending _
                                 Select ob).ToList()
    
    
        'Map it to the ViewModel
        ovm = AutoMapper.Mapper.Map(Of Organization, OrganizationViewModel)(o)
    
        Return View(ovm)
    
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Index.cshtml view: @model AttendenceModel @{ Layout = ~/Views/Shared/_Layout.cshtml; } @using (Html.BeginForm(VisOppsummering,
I have the following in my Razor view: @using (Html.BeginForm(Edit, MyController, FormMethod.Post)) { <div
Following Brad Wilson's excellent series on using and customizing editor templates , I tried
Instead of using a CheckBoxList helper control I want to use the editor templates
I compiled the following code as a shared library using g++ -shared ... :
I'm trying to display a view model using an editor template that wraps the
I am using the shared preferences editor to store numbers to save and use
I am using this, an editor template (located in the Shared\EditorTemplates folder in my
I am trying to use a partial view editor template in my application using
I'm writing login capability using share preference. I use SharedPreferences.Editor::commit() to store username and

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.