I’m searching for a good way to bind a List<string> to a form in MVC3. Right now I have 2 options:
- Use a ListBox with a textbox, add/delete button in jquery and do a select all items before posting my form
- Use a
<li>that will contains a<input type="hidden" />with the value also with a add/delete button in jquery
I’m sure there is easyer way to do this but I did not found anything here so I’m asking for help. My concern is to add different bussiness units (string) to a company while editing the company other properties (name, address..).
Thanks!
Here’s my code for the first option, if anyone find a better solution, let me know!
Html/Razor :
Js :
The SelectList :
It will bind to my property
public virtual IList<string> BusinessUnits { get; set; }in my model.Hope it can helps!