I have a model
public class DynamicFields
{
public string propertyName { get; set; }
public string propertyType { get; set; }
}
This will be populated as List in my controller.
Now i need to render controls dynamically in View based on propertyType text value. If value is "TextBox" I need to render textbox control. So I have used editorfor control.
View,
@model IEnumerable<DynamicFields>
@foreach(var field in Model)
{
@Html.LabelFor(model => field.propertyName)
@Html.EditorFor(model => field.propertyName, field.propertyType)
}
I don't know how to handle this in case of DropDownList.
Thanks in advance for your help.