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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:46:12+00:00 2026-06-12T20:46:12+00:00

I am trying to make a stock take application, My view loads all my

  • 0

I am trying to make a stock take application, My view loads all my stock with one editor.
My controller is not getting any of the data from the view?

I want to be able to edit all my stock at the same time?
How can I do this

Model Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace FlatSystem.Models
{
public class Stock
{
    public int ID { get; set; }
    public string Item_Name { get; set; }
    public int Actual_Stock { get; set; }
    public int Wanted_Stock { get; set; }


}
}

View Code

@model IEnumerable<FlatSystem.Models.Stock>

@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<div class="sidemenu">
<div class="sidemenu-heading">
    ReStock
</div>
<div class="div-body">
<table>
<tr>
    <th>
        Item Name
    </th>
    <th>
        Wanted Stock
    </th>
    <th>
        Stock On Hand
    </th>
    <th></th>
</tr>
@foreach (var item in Model)
{
<tr>
    <td>
        @Html.DisplayFor(modelItem => item.Item_Name)
    </td>
    <td>
        @Html.DisplayFor(modelItem => item.Wanted_Stock)
    </td>
    <td>
    <div class="editor-field">
        @Html.EditorFor(modelItem => item.Actual_Stock)
        @Html.ValidationMessageFor(modelItem => item.Actual_Stock)
    </div>
    </td>
    @Html.HiddenFor(modelItem => item.ID)
    </tr>
    }
    </table>
    </div>
    </div>
<input type="submit" value="Submit" />
}

Controller Code

        [HttpPost]
    public ActionResult ReStock(List<Stock> stock)
    {
        foreach (var item in stock)
        {
            if (ModelState.IsValid)
            {
                GR.InsertOrUpdate(item);
            }
        }
        GR.Save();
        return RedirectToAction("Restock");
    }
  • 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-12T20:46:13+00:00Added an answer on June 12, 2026 at 8:46 pm

    It’s hard to answer your question without model class, but idea is that your edit inputs must contain index in name attribute.

    Something like this:

    @for(int i = 0: i < Model.Count(); i++)
    {
        <tr>
        <td>
            @Html.DisplayFor(modelItem => Model[i].Item_Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => Model[i].Wanted_Stock)
        </td>
        <td>
        <div class="editor-field">
            @Html.EditorFor(modelItem => Model[i].Actual_Stock)
            @Html.ValidationMessageFor(modelItem => Model[i].Actual_Stock)
        </div>
        </td>
        @Html.HiddenFor(modelItem => Model[i].ID)
        </tr>
    }
    

    Added:

    Sorry, thanks to Darin Dimitrov, you can’t access IEnumerable by index, use List or Array.

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

Sidebar

Related Questions

I was trying to make a code that will take input from a user
Ok, I'm trying to take several divs and all their content, and stack them
I am trying to make a new application and I would like to get
I am trying to make a new application and I would like to get
I’m trying to make something that will take lines of input from the user,
I am trying to make this query work: SELECT Stock.*, StockFeatures.Features, StockDescriptions.Detailed, StockDescriptions.Technical, PRD1.RuleValue
I am trying to write a function which can take any of the standard
I'm trying to make an auto login script and I'm stuck on the submit
Hey I am trying to make a dungeon crawler and I am stuck on
i'm trying to make my second website using php and i'm stuck at some

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.