Setting DisplayFormat at Model

You can set how you want to format your data at Model level by using DisplayFormat. It is simple yet deep and worthy to master.

Microsoft put documents here:

Typically when you have numerical value in your database, it is stored like “123123121”.  But I want to show it like “123,123,121” for better readability, then simply make your model like below;

You can format at view level too, but if you are using one model at multiple views and you want all views to have them in same format, this is better.

DisplayFormat for date and time

If you need to know more about date time format please read: https://msdn.microsoft.com/en-us/library/system.datetime(v=vs.110).aspx

Leave a Reply