difference between: [ScaffoldColumn (false)] and [Display (AutoGenerateField = false)]

点点圈 提交于 2019-12-05 06:33:19

The EditorForModel() and DisplayForModel() Html helper methods makes decision of rendering view of the properties of the current Model based on the ViewData.ModelMetadata. The default DataAnnotationsModelMetadataProvider sets the properties of ModelMetadata based on the DataAnnotation attributes.

ScaffoldColumnAttribute.Scaffold affects two properties of ModelMetadata i.e. 'ShowForDisplay' and 'ShowForEdit'.

DisplayAttribute does not affects the above two properties of ModelMetadata.

That is why these two attributes do not have the same effect on generating Html.

I also wanted to know the difference, the following is from MSDN - http://msdn.microsoft.com/en-us/library/dd411771(v=vs.95).aspx

"AutoGenerateField - A value that indicates whether the field is included in the automatic generation of user-interface elements such as columns. This value is used by the DataGrid control."

From this it appears that this particular property is meant for DataGrid only.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!