One problem I ran into was how to change the column display name since my database uses column names with underscores for spaces and I want an actual space between parts of the column name when using the app. To do this you need to use the Display Name attribute in your meta class. Unfortunately this attribute only works on a full property and not on a simple object like other System.ComponentModel attributes seem to. So in my Meta Data class I created a dummy property with the same name as the actual property I want to change the display name for.
Public Property Address_Type() As String
'These are not actually used, they are just required to make this into
'a true property which is required for the DisplayName Attribute.
Get
Return ""
End Get
Set(ByVal value As String)
End Set
End Property
Here is the entire class for you to look at:
Imports Microsoft.VisualBasic
Imports System.Web.DynamicData
Imports System.ComponentModel
Imports System.ComponentModel.DataAnnotations
<MetadataType(GetType(CHMS_Address_TypeMetaData))> _
Partial Public Class CHMS_Address_Type
End Class
<TableName("Address Types")> _
Public Class CHMS_Address_TypeMetaData
<DisplayName("Address Type")> _
Public Property Address_Type() As String
'These are not actually used, they are just required to make this into
'a true property which is required for the DisplayName Attribute.
Get
Return ""
End Get
Set(ByVal value As String)
End Set
End Property
'Columns I want hidden
<ScaffoldColumn(False)> _
Public Church_ID As Object
<ScaffoldColumn(False)> _
Public Created As Object
<ScaffoldColumn(False)> _
Public Created_By As Object
<ScaffoldColumn(False)> _
Public Last_Edited As Object
<ScaffoldColumn(False)> _
Public Last_Edited_By As Object
<ScaffoldColumn(False)> _
Public IsDeleted As Object
End Class
No comments:
Post a Comment