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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:04:25+00:00 2026-06-09T08:04:25+00:00

So I have the following code: @model Project.Models.ViewModels.SomeViewModel @using (Html.BeginForm(SomeAction, SomeController, new { id

  • 0

So I have the following code:

@model Project.Models.ViewModels.SomeViewModel
@using (Html.BeginForm("SomeAction", "SomeController", new { id = Model.Id}))
        {
            for(int i = 0; i < Model.SomeCollection.Count(); i++)
            {
                @Html.HiddenFor(x => Model.SomeCollection.ElementAt(i).Id)
                <div class="grid_6">
                    @Html.TextAreaFor(x => Model.SomeCollection.ElementAt(i).Text, new { @style = "height:150px", @class = "grid_6 input" })
                </div>
            }
            <div class="grid_6 alpha omega">
                <input type="submit" value="Next" class="grid_6 alpha omega button drop_4 gravity_5" />
            </div>
        }

On the Controller Side I have the following:

[HttpPost]
        public ActionResult SomeAction(int id, SomeViewModel model)
        {

            return PartialView("_SomeOtherView", new SomeOtherViewModel(id));
        }

My View Model is set up like this:

public class SomeViewModel
{
        public SomeViewModel()
        {

        }
        public IEnumerable<ItemViewModel> SomeCollection { get; set; }

}

public class ItemViewModel{

      public ItemViewModel(){}

      public int Id {get;set;}

      public string Text{get;set;}

}

The SomeCollection is always empty when SomeAction if performed. What do I have to do in order to show the updated values by users. Text Property and Id field.

  • 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-09T08:04:26+00:00Added an answer on June 9, 2026 at 8:04 am

    Use an EditorTemplate

    Create an EditorTemplate folder under your Views/YourcontrollerName and create a view with name ItemViewModel.cshtml

    enter image description here

    And Have this code in that file

    @model  Project.Models.ViewModels.ItemViewModel
    <p>
     @Html.EditorFor(x => x.Text) 
     @Html.HiddenFor(x=>x.Id)
    </p>
    

    Now from your Main view, call it like this

    @model  Project.Models.ViewModels.SomeViewModel
    @using (Html.BeginForm("SomeAction", "Home", new { id = Model.Id}))
    {
        @Html.EditorFor(s=>s.SomeCollection)
        <div class="grid_6 alpha omega">
            <input type="submit" value="Next" class="grid_6 alpha omega button drop_4 gravity_5" />
        </div>
    }
    

    Now in your HTTPPOST method will be filled with values.

    I am not sure what you want to do with the values( returning the partial view ?) So not making any comments about that.

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

Sidebar

Related Questions

In my view I have the following code: @using (Html.BeginForm()) { @Html.TextBox(Date2, Model.Date2) <br/>
I have the following code in a view: <div class=wrap_select> @Html.DropDownList(dateRange, new SelectList(Model.DateRange, Value,Text),
I'm developing application using backbone.js & jquery. I have following code in model: runReport:
I'm using the Code First approach and have the following Model: public class Person
I have the following code: private Models.mediamanagerEntities dataModel = new Models.mediamanagerEntities(); public ActionResult Index(FormCollection
I have the following setup (pseudo coffee code). Models and collections are loaded using
I have the following code in my model: attr_accessor :expiry_date validates_presence_of :expiry_date, :on =>
I have code like following: switch(sort.Column) { case code: model = (sort.Direction == SortDirection.Ascending)
i have the following code in the rails company model: class Company include Mongoid::Document
I have the following code to generate a table listing brand/model/submodel/style for a group

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.