ASP MVC dynamic fields in editor
Posted
by Michael Pardo
on Stack Overflow
See other posts from Stack Overflow
or by Michael Pardo
Published on 2010-05-17T19:15:39Z
Indexed on
2010/05/17
19:31 UTC
Read the original article
Hit count: 244
I have a form which will include some optional questions that need to asked of the user. In my model it may look like
pubic Dictionary<String, String> Questions { get; set; }
where the key is the label and value is the text box. How can I create and populate controls for this? I'm new to ASP MVC, but it makes sense that something like this would be built in.
Is there a built in way to do this, or do I have to implement it myself? It seems like there should be a helper for it, since you don't really want to put this kind of code in the view.
I've tried
Html.EditorFor(model => model.Questions);
but it just spits out "[key, value]" to the view.
© Stack Overflow or respective owner