https://www.geekmcq.com/
CSS Solved Papers
Physics Chemistry

Engineering :: Asp.net MVC


  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) {
@property.GetDisplayName()

}

Write your comments here:
Name *:     Email:

© 2012-2024 by GeekMCQ™ Technologies. All Rights Reserved | Copyright | Terms of Use & Privacy Policy | Referals

Contact us: info@geekmcq.com