Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi,
I am fairly new with Hands On MVC, So I wanted to know if there is a simple solution to my problem. I have a model class whose scaled down version is given below : -

C#
public class Driver
{
    public int ID { get; set; }

    [Required]
    [Display(Name = "Name")]
    public string FName { get; set; }

    [Display(Name = "IsActive")]
    public bool IsActive { get; set; }

    [Display(Name ="Is Vendor")]
    public bool IsVendor { get; set; }

    [Required]
    public string IFSCCode { get; set; }

    [Required]
    public string AccountNumber { get; set; }       
}

Now I need one of my property to be displayed differently in different views e.g. I need the IsVendor property to be display as "Is Vendor" when I show the list of Drivers in a grid and when I show the "Create New Driver" View using the same model I need to show it as

C#
I am a vendor

checkbox input type.

What I have tried:

I used Display Attribute and tried to override it in one of the views, but I don't know what and how to get it done, I don't even know if such a thing is possible. Please help.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900