Loading DB Table Fields dynamically in Razor @foreach (var property in ViewData.ModelMetadata.Properties)
{
@Html.Editor(property.PropertyName)
}
this code runs only in CRUD files...and for index page where we have
@model IEnumerable it works as
@{
var metadata = ModelMetadata.FromLambdaExpression(m => m.ToArray()[0], ViewData);
var properties = metadata.Properties;
}
@foreach (var property in properties)
{