asp.net mvc 3 - MVC Razor Rendering controls dynamically -
this 1 way i've found render controls dynamically asp.net mvc 3 razor. giving me correct data, i'm curious if sees red flags method, or painfully more obvious way 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> } }
you use editor , display templates instead...
check out link:
http://blogs.msdn.com/b/nunos/archive/2010/02/08/quick-tips-about-asp-net-mvc-editor-templates.aspx
Comments
Post a Comment