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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:08:36+00:00 2026-05-25T03:08:36+00:00

ViewModel class public class CreateMRViewModel { public Decimal? Freight { get; set; } public

  • 0

ViewModel class

public class CreateMRViewModel
{
    public Decimal? Freight { get; set; }
    public IList<OrderLine> OrderLines { get; set; }
}

public class OrderLine
{
    public string LineNumber { get; set; }
    public string VendorPartNumber { get; set; }
    public long? Quantity { get; set; }
    public string UOM { get; set; }
    public decimal PricePerUom { get; set; }
    public long? ReturnQuantity { get; set; }
    public long? QuantityAvaiToReturn { get; set; }
}

My View

@model CreateMRViewModel
@using (Html.BeginForm()) {
<fieldset>
    <table>
        <tr>
            <th>Line Number</th>
            <th>Part Number</th>
            <th>UOM</th>
            <th>PricePerUom</th>
            <th>Available Qty</th>
            <th>Return Qty</th>
        </tr>
        @for (int i = 0; i < Model.OrderLines.Count; i++)
        {
        <tr>
            <td>@Html.DisplayFor(modelItem => Model.OrderLines[i].LineNumber)</td>
            <td>@Html.DisplayFor(modelItem => Model.OrderLines[i].VendorPartNumber)</td>
            <td>@Html.DisplayFor(modelItem => Model.OrderLines[i].UOM)</td>
            <td>@Html.DisplayFor(modelItem => Model.OrderLines[i].PricePerUom)</td>
            <td>@Html.DisplayFor(modelItem => Model.OrderLines[i].Quantity)</td>
            <td>@Html.TextBoxFor(modelItem => Model.OrderLines[i].ReturnQuantity)</td>
        </tr>
        }
    </table>
    <br />
    <div class="display-label">@Html.LabelFor(model => Model.Freight)</div>
    <div class="display-field">@Html.TextBox("Freight", new Int64())</div>
    <br />
    <br />
    <input class="submitForm" type="submit" value="Create Return" />
</fieldset>
}

Action Controller

[HttpPost]
public ActionResult CreateMR(CreateMRViewModel mrViewModel)
{
    //some code here
}

My problem is: I get the CreateMRViewModel to controller but only textbox values are available for me to use. How can I get the displayed values such as LineNumber or VendorPartNumber for use in controller method?

  • 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-25T03:08:37+00:00Added an answer on May 25, 2026 at 3:08 am

    You’re not actually posting any values for those Properties since you’re using DisplayFor()

    If you simply want to just pass it through to the [HttpPost] method you’re going to need to represent it with a hidden input or make it editable.

    <td>
        @Html.DisplayFor(modelItem => Model.OrderLines[i].VendorPartNumber)
        @Html.HiddenFor(modelItem => Model.OrderLines[i].VendorPartNumber)
    </td>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My ViewModel: class ViewModel { public string FileName {get;set;} } and in my View
Suppose you have a viewModel: public class CreatePersonViewModel { [Required] public bool HasDeliveryAddress {get;set;}
Given the following viewmodel: public class SomeViewModel { public bool IsA { get; set;
I have a simple ViewModel class like public class TestViewModel { public String Information
I have the following nested viewmodel class... public class CustomerModel { public string name;
Suppose I have this model: public class ViewModel { [Required] public string UserInput {
I have a ViewModel : public class VM { public ObservableCollction<PersonRole> PersonRoles { get;
I have a class that roughly looks like this: public class ViewModel { public
I have a viewmodel that contains a product and SelectList of categories. public class
Ok, i got a viewmodel as follows: public class PageViewModel { public Item Item

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.