This is one way I've found to render controls dynamically with ASP.NET MVC 3 Razor. This is giving me correct data, but I'm curious if anyone sees any red flags with this method, or a painfully more obvious way to do this.
@using (Html.BeginForm())
{
foreach (var item in Model)
{
<tr>
<td>
@item.app_name
</td>
<td>
@item.setting_name
</td>
<td>
@item.setting_description
</td>
<td>
@if (item.data_type == "Bit")
{
@Html.CheckBox("setting_value", item.setting_value == "1" ? true : false)
}
else
{
@Html.TextBox("setting_value", item.setting_value)
}
</td>
<td>
@item.setting_value
</td>
</tr>
}
}