I have a list of elements in my form that are named like this ...
<input type="text" id="ListItem1" name="ListItem1"> <input type="text" id="ListItem2" name="ListItem2"> <input type="text" id="ListItem3" name="ListItem3">
I want to create a custom binder that converts them to a model with this structure ...
public class MyModel { public IEnumerable<MyModelItem> Items {get; set;} } public class MyModelItem { public int Id { get; set; } public string Value { get; set; } }
Thus, each ListItem must be converted to MyModelItem with an identifier equal to the number at the end of the input identifier, and the value set to the value in the input field.
In ASP.Net MVC 1.0, I could bindingContext.ValueProvider.Keys over the bindingContext.ValueProvider.Keys collection and check on key.StartsWith("ListItem") to find all input elements in this format.
The new IValueProvider interface in ASP.Net MVC 2 does not have a collection of keys, and I cannot iterate over this interface. How to access these values ββthat I know only for the prefix during development in ASP.Net MVC 2?
asp.net-mvc
Noob
source share