Part 41 Using datatype and displaycolumn attributes in asp net mvc application

Video is ready, Click Here to View ×


In this video, we will discuss using datatype and displaycolumn attributes. Please watch Part 40, before proceeding.

Note: In code samples, please replace [ with LESSTHAN character, and ] with GREATERTHAN character

To understand DataType attribute, we will be using the same example, we used in Part 40. Copy and paste the following code in “Employee” class, and navigate to localhost/MVCDemo/Home/Details/1.
[MetadataType(typeof(EmployeeMetaData))]
public partial class Employee
{
}

public class EmployeeMetaData
{
// Display mailto hyperlink
[DataType(DataType.EmailAddress)]
public string EmailAddress { get; set; }

// Display currency symbol. For country specific currency, set
// culture using globalization element in web.config.
// For Great Britain Pound symbol
// [globalization culture=”en-gb”/]
[DataType(DataType.Currency)]
public int? Salary { get; set; }

// Generate a hyperlink
[DataType(DataType.Url)]
public string…

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.