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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:53:16+00:00 2026-06-06T04:53:16+00:00

I have this view @model IEnumerable<ViewModelRound2> … <snip> … @{ using (Html.BeginForm(new { round1Ring3Bids

  • 0

I have this view

@model IEnumerable<ViewModelRound2>

... <snip> ...

@{
    using (Html.BeginForm(new { round1Ring3Bids = Model }))
    {
        if (Model != null && Model.Count() > 0)
        {
                ... <snip> ...

                @for (var x = 0; x < Model.Count(); x++)
                {
                    ViewModelRound2 viewModelRound2 = Model.ElementAt(x);
                    Bid bid = viewModelRound2.Bid;

                    string userName = @bid.User.Invitation.Where(i => i.AuctionId == bid.Lot.Lot_Auction_ID).First().User.User_Username;

                    <tr>
                        <td>
                            @userName
                        </td>
                        <td>
                            @bid.Bid_Value
                        </td>
                        <td>
                            @Html.EditorFor(c => c.ElementAt(x).SelectedForRound2) 
                        </td>
                    </tr>
                }

            </table>

            <div class="buttonwrapper2">
                <input type="submit" value="Select"/>              
            </div>
        }
    }
}

I have a post method that this goes to when the submit button is hit

[HttpPost]
        public ActionResult Round2Manager(IEnumerable<ViewModelRound2> round1Ring3Bids)

Problem is that the enumeration is always empty. Why is this?

  • 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-06T04:53:18+00:00Added an answer on June 6, 2026 at 4:53 am

    Problem is that the enumeration is always empty. Why is this?

    Because you are not respecting the wire format that the default model binder expects to bind collections.

    The following:

    @Html.EditorFor(c => c.ElementAt(x).SelectedForRound2) 
    

    generates absolutely wrong names for your input fields.

    I would recommend you using editor templates to avoid those kind of problems:

    @model IEnumerable<ViewModelRound2>
    
    @using (Html.BeginForm())
    {
        if (Model != null && Model.Count() > 0)
        {
            <table>
                @Html.EditorForModel()
            </table>
            <div class="buttonwrapper2">
                <input type="submit" value="Select"/>              
            </div>
        }
    }
    

    and then define a custom editor template for the ViewModelRound2 type (~/View/Shared/EditorTemplates/ViewModelRound2.cshtml) which will automatically be rendered for each element of this collection:

    @model ViewModelRound2
    @ {
        string userName = Model.Bid.User.Invitation.Where(
            i => i.AuctionId == Model.Bid.Lot.Lot_Auction_ID
        ).First().User.User_Username;
    }
    
    <tr>
        <td>
            @userName
        </td>
        <td>
            @Model.Bid.Bid_Value
        </td>
        <td>
            @Html.EditorFor(c => c.SelectedForRound2) 
        </td>
    </tr>
    

    You will now notice how the text input fields have correct names:

    name="[0].SelectedForRound2"
    name="[1].SelectedForRound2"
    name="[2].SelectedForRound2"
    ...
    

    Compare this with your initial values.

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

Sidebar

Related Questions

I have a PaartialView declared like this: @model IEnumerable<mvc1.Models.ProjectDetailModel> @using (Html.BeginForm()) <form method=get action=EditProject
Hi I have this code in my view.. <%=Html.DropDownList(ProductTemplate,new SelectList(Model.ProductTemplate,Value,Text))%> I know if this
I have this this View for rendering form @using ExpertApplication.ViewModels @model IEnumerable<QuestionViewModel> @{ ViewBag.Title
I have a view model that looks like this public class ViewModelRound2 { public
I have the following partial view code @model IEnumerable<PDoc.Web.Models.UserDocModel> @using MvcContrib.UI.Grid; @using MvcContrib.UI.Pager; @using
I have this attribute in my view model: [CustomRequired, EmailRegex] [Display(Name = KeepInformedPersonMail, ResourceType
I have code like this in my view model: function ChatListViewModel(chats) { var self
I have a view model coming from the server as json like this {
Let's say I have a QTableView with a corresponding model. This view shows numbers
I have a model that gets it's view-count updated after it's viewed. This is

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.