Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Data annotation inside MVC6 web grid

$
0
0

I have added the following model class inside my asp.net MVC core web application 3.1:-

[ModelMetadataType(typeof(Submission_Validation))]
    public partial class Submission
    {


    }

and the following Submission_Validation class:-

public class Submission_Validation
    {

[DisplayFormat(ApplyFormatInEditMode = true,
DataFormatString = "{0:dd MMMM yyyy hh:mm:ss tt}")]
public DateTime Created { get; set; }
    }

now if i show the Created field using @Html.DisplayFor(model => model.Created) the date will have the correct format as specified inside the data annotation, but if i render the value inside the MVC-6-Grid (https://mvc6-grid.azurewebsites.net/) as follow:-

@(Html
    .Grid(Model)
    .Build(columns =>
    {
columns.Add(model => model.Created).Titled("Created")
})
    .Using(GridFilterMode.Header)
    .Empty("No data found")
    .Filterable()
    .Sortable()
    .Pageable(pager =>
    {

        pager.RowsPerPage = 250;
    })

the date will ignore the data annotation specified. any idea how i can fix this?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>