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



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…

5 Comments on “Part 41 Using datatype and displaycolumn attributes in asp net mvc application”

  1. i still don't add Employee partial Class ? if i going add its duplicate i got a validation error on auto generated Attributes? so now how can i add modified these changes which we were on 40 and 41 part of video ? if any one can help me plz ?

  2. This is discussed in the initial videos of MVC tutorial. In the description of this video, I have included the link for MVC, C#, and SQL Server playlists. All the videos are arranged in logical sequence in these playlists, which could be useful to you. Please share the link with your friends who you think would also benefit from them. If you like these videos, please click on the THUMBS UP button below the video. For email alerts, when new videos are uploaded, you may subscribe to my channel.

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.