purplehaze1
Programmer
I am binding datagrid to collection (orequests) to display customer requests.
How do you format datagrid which has collection as datasource? what mapping name to use? i.e. oRequests.GetType.Name did not work. Currently, even though I want only selected fields contaied in collection objects to appear on datagrid, it displays every fields included in the class 'request'. Thanks again.
Dim grdTableStyle1 As New DataGridTableStyle()
With grdTableStyle1
.AlternatingBackColor = Color.GhostWhite
.MappingName = oRequests.GetType.Name ' this did not work.
.PreferredColumnWidth = 200
.PreferredRowHeight = 20
End With
Dim grdColStyle1 As New DataGridTextBoxColumn()
With grdColStyle1
.HeaderText = "First Name"
.MappingName = "first_nme"
.Width = 100
End With
Dim grdColStyle2 As New DataGridTextBoxColumn()
With grdColStyle2
.HeaderText = "Request Type"
.MappingName = "request_type_desc"
.Width = 100
End With
grdTableStyle1.GridColumnStyles.AddRange _
(New DataGridColumnStyle() _
{grdColStyle1, grdColStyle2}
grdRequest.TableStyles.Add(grdTableStyle1)
How do you format datagrid which has collection as datasource? what mapping name to use? i.e. oRequests.GetType.Name did not work. Currently, even though I want only selected fields contaied in collection objects to appear on datagrid, it displays every fields included in the class 'request'. Thanks again.
Dim grdTableStyle1 As New DataGridTableStyle()
With grdTableStyle1
.AlternatingBackColor = Color.GhostWhite
.MappingName = oRequests.GetType.Name ' this did not work.
.PreferredColumnWidth = 200
.PreferredRowHeight = 20
End With
Dim grdColStyle1 As New DataGridTextBoxColumn()
With grdColStyle1
.HeaderText = "First Name"
.MappingName = "first_nme"
.Width = 100
End With
Dim grdColStyle2 As New DataGridTextBoxColumn()
With grdColStyle2
.HeaderText = "Request Type"
.MappingName = "request_type_desc"
.Width = 100
End With
grdTableStyle1.GridColumnStyles.AddRange _
(New DataGridColumnStyle() _
{grdColStyle1, grdColStyle2}
grdRequest.TableStyles.Add(grdTableStyle1)