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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:29:12+00:00 2026-06-03T19:29:12+00:00

The ViewModel looks like this: public W { get; set; } public WC WC

  • 0

The ViewModel looks like this:

public W { get; set; }
public WC WC { get; set; }
public List<TC> TCs { get; set; }

WC has a correlated group of TC. Their relation is mapped by TC containing the foreign key WCId.

In the view, I have a form. In the form, there are input fields for WC. Then, there is a group of TC depending on a count with a max of 4. Each TC has a related T in that TC has a foreign key TCId. I am trying to make sure that when the form is posted TC has the correlating TId. The TId is held in a list of T in W (i.e. @Model.W.T.ElementAt(someindex).TId).

How can I levarage a lambda expression to use the helpers to generate this relation in the view so it can be consumed in a httppost action by the correlating controller?

Here is what I am doing right now:

<input type="hidden" value="@(Model.W.T.ElementAt(i).TId)"
 name="TCs[@(i)].TId" 
 id="TCs_@(i)__TId" data-val="true"/>

What I would like to do is use the @Html.HiddenFor helper but cannot seem to get it to work so I just used the slightly dynamic yet still hardcoded approach above. Note: this works, however, I would like it to be cleaner.

  • 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-06-03T19:29:14+00:00Added an answer on June 3, 2026 at 7:29 pm

    What you’re doing right now is -as far as I know – the only way to do it. I don’t know of a way for a simpler @Htm.HiddenFor(…) version. I’ve been dealing with similar issues too. Nevertheless, if you think that you could reuse the pattern above you can still create your own Display/Editor template or other more abstract ways. Of course they’ll be more verbose and complex than your “ugly” but straight forward approach.

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

Sidebar

Related Questions

I have a class that roughly looks like this: public class ViewModel { public
My ViewModel looks like this: public class DirectoryViewModel : ViewModelBase { public ObservableCollection<DirectoryViewModel> SubDirectoryList
I have a ViewModel that looks like this: public class CreateReviewViewModel { public string
Ok, I have a ViewModel that looks like this: public class UserLogin { [Required]
I my view model(LIST) looks like this: public class ConversationModel { public int ID
I have a viewmodel that partially looks like this... [Required] public int Year {
I have a view model that looks like this: public class VenueIndexViewModel : BaseViewModel
Suppose you have a viewModel: public class CreatePersonViewModel { [Required] public bool HasDeliveryAddress {get;set;}
If i have a ViewModel like this: public class MyViewModel { [UIHint(SomeTemplate)] public ICollection<SomeViewModel>
My simplified domain model looks something like this: public abstract class Entity<IdK> { public

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.