J
Jeff Bunting
I'm trying to create a datatable based on the properties of a class. I've
got this
Dim DT As New DataTable
Dim t As Type = Me.GetType
Dim ObjectMembers As MemberInfo() = t.GetProperties
Dim Iterator As MemberInfo
For Each Iterator In ObjectMembers
ColName = Iterator.Name.ToString
ColType = Iterator.GetType
myNewCol = New DataColumn(ColName, ColType)
DT.Columns.Add(myNewCol)
Next
ColType = Iterator.GetType isn't correct though. I want to get the type of
the class property but this is giving me the type of Iterator. I've tried
several variations but haven't hit on the proper syntax. Can someone help
please?
Jeff
got this
Dim DT As New DataTable
Dim t As Type = Me.GetType
Dim ObjectMembers As MemberInfo() = t.GetProperties
Dim Iterator As MemberInfo
For Each Iterator In ObjectMembers
ColName = Iterator.Name.ToString
ColType = Iterator.GetType
myNewCol = New DataColumn(ColName, ColType)
DT.Columns.Add(myNewCol)
Next
ColType = Iterator.GetType isn't correct though. I want to get the type of
the class property but this is giving me the type of Iterator. I've tried
several variations but haven't hit on the proper syntax. Can someone help
please?
Jeff