DataType vs UiHint

后端 未结 2 1388
一向
一向 2021-02-13 01:12

I have been using mvc2 for a while now, and when i need to set the template i use the DataType Attribute

    [DataType(\"DropDown\")]
    public int         


        
2条回答
  •  走了就别回头了
    2021-02-13 01:51

    DataType is generally used to make it known that this is a very specific version of a property, such as price.

    The most common example of DataType is the [DataType(DataTypes.EmailAddress)] which usually is a string but we're saying that this is a very specific type of string.

    They're both helpful and the UIHint overrides the DataType. So if you have a certain DataType but you want to override the editor for that specific property you can use a UIHint.

提交回复
热议问题