C # MVC3 binding IEnumerable Model to table

I am working on a university project and am learning MVC3 at the same time. I have a cart style page with a table showing the items. The model contains a list of purchased products.

I can display products in a table through a loop through the model and display, however I need to implement a way to update the quantity. Currently I have values ​​displayed in HTML.TextBox that can be changed, but when I change the value it is not represented as such in the model.

Can someone please advise how I could do this.

Thank.

+3


source to share


1 answer


To update the model, you will post the edited values ​​to the server. To populate the model values ​​in a text box, you can use the Html.EditorFor extension method and pass a pointer to the quantity property in the lambda expression. You can put the cart controls in an HTML form control with a "post" action and a target controller route that will update the model. These are very simple operations in Asp.Net MVC and you should be able to see how it is done in www.asp.net/MVC



Please do some research before posting your questions on the forum.

0


source







All Articles