Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formatting datagrid with data from collection

Status
Not open for further replies.

purplehaze1

Programmer
Jul 23, 2003
86
0
0
US
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)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top