I am creating a pageant scoring system.

I managed to display the field names from different tables :

Click Here

The first column "Participants" is from Participant table and the succeeding columns is looped from the Criteria table.

This is the code:

Private Sub CreateDataEntry(ByVal CatID As Integer)
Me.CriteriaTableAdapter.FillByCategory(Me.PSSdbDataSet.Criteria, CatID)

DataGridView.Rows.Clear()
DataGridView.Columns.Clear()

' construct data entry
' first column (participants)
Dim nc As New DataGridViewTextBoxColumn
nc.Name = "Participants"
nc.Width = 250
nc.ReadOnly = True
DataGridView.Columns.Add(nc)
nc = Nothing
' succeeding columns (criteria)
For Each drCriteria As DataRow In Me.PSSdbDataSet.Criteria.Rows
    nc = New DataGridViewTextBoxColumn
    nc.Name = drCriteria("Cri_desc") & Chr(13) & drCriteria("Cri_percent") & "%"
    nc.HeaderText = drCriteria("Cri_desc") & " " & drCriteria("Cri_percent") & "%"
    nc.Width = 100
    DataGridView.Columns.Add(nc)
Next
End Sub

Now, how can I fill the participant's row from the database? and the Criteria rows must be blank so I can input scores.. Thanks.

This must be the expected result:

Click Here

My suggestion would be to join the tables from the backend then pass the joined row to your DataGridView.

For example:

"SELECT pt.Participant, cr.Chri_Percent FROM Participants pt, Chriteria cr WHERE pt.UniqueIDValue = cr.UniqueIDValue"

This will bind the two data rows into one data row.

This WILL require a one to one relationship in the tables.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.