In this post we see how we can bind to editable IEnumerables-Lists in an ASP.NET MVC view and get the updated values in our HttpPost action. Moreover, we see how we can use JQuery to dynamically add/remove items from the list and have our updates transferred to the HttpPost action. We start by defining a simple class named Client which will be our list element: public class Client { public string FirstName { get ; set ; } public string LastName { get ; set ; } } We implement an Action method that creates a list of Client objects: public ViewResult Simple() { List < Client > Clients = new List < Client >(); Clients.Add( new Client { FirstName = "Giannis" , LastName = "Panagopoulos" }); Clients.Add( new Client { FirstName = "Kostas" , LastName = "Papadopoulos" }); Clients.Add( new Client { FirstName = "Petros" , LastName = "Georgiadis" }); return View(Clients); } The simple view renders the list as follows (with input elements of type text for
Διαβάστε περισσότερα »
Another year in Berlin! Another chance to learn great things on Microsoft Technologies.
Διαβάστε περισσότερα »