Of course you cannot make it work that way
First of all, you should know that model binding occurs mainly using sending data from inputs on the client side. Html.DisplayTextFor
helper does not generate input, it generates plain text. Texts do not participate in the data sent by the client when submitting the form, so you will not get them bound to the model. If you look at the Request.Form
property, you should see a proof - there are no description fields.
What you can do if you want to display the text, as well as allow the description to participate in the values ββof the form, is to use a hidden field. MVC got an assistant for this
@for (int i = 0; i < Model.FullOrder.OrderList.Count(); i++) { <tr> <td> @Html.DisplayTextFor(m => m.FullOrder.OrderList[i].Description) @Html.HiddenFor(m => m.FullOrder.OrderList[i].Description) </td> <td> @Html.TextBoxFor(m => m.FullOrder.OrderList[i].Qty, new { @style = "width:50px;" }) </td> </tr> }
Thus, the submitted form will also contain description values
archil
source share