Hi all

I am having a bit of trouble with populating a gridviewcombobox with data from a SQL query.

My form has a gridview and a ComboBox. Depending what they select in the ComboBox depends on what routine they run

Code:
            If CBFileFormat.Text = "Spooler File" Then

                Dim linelist As New DataGridViewTextBoxColumn
                With linelist
                    .DataPropertyName = "Line"
                    .HeaderText = "Line Number"
                    .Width = 75

                End With

                Dim posslist As New DataGridViewTextBoxColumn
                With posslist
                    .DataPropertyName = "Position"
                    .HeaderText = "Position Number"
                    .Width = 75

                End With
                Dim widthlist As New DataGridViewTextBoxColumn
                With widthlist
                    .DataPropertyName = "Width"
                    .HeaderText = "Field Width"
                    .Width = 75

                End With
                Dim targetlist As New DataGridViewComboBoxColumn
                With targetlist
                    .DataPropertyName = "Target List"
                    .HeaderText = "Target Field"
                    .DropDownWidth = 180
                    .Width = 150
                    .FlatStyle = FlatStyle.Flat
                    For Each item As String In TargetArray
                        .Items.Add(item.ToString)
                    Next
                End With
                DG.Columns.Add(linelist)
                DG.Columns.Add(posslist)
                DG.Columns.Add(widthlist)
                DG.Columns.Add(targetlist)

                If DG IsNot Nothing Then
                    Dim count As Integer = 0
                    DG.RowHeadersWidth = 70
                    While (count <= (DG.Rows.Count - 2))
                        DG.Rows(count).HeaderCell.Value = String.Format((count + 1).ToString(), "0")
                        count += 1
                    End While
                End If
            End If
        Catch ex As Exception
            MsgBox("Error " & vbCrLf & RN & ex.Message)
        End Try
Once this has ran I go away and collect the data from the sql.

Code:
    Private Sub PullBackSpooler()
        Dim rn As String = "Pull Back Spooler File"
        Try
            If ifloaded = True Then

                Dim sqlsettings As SqlCommand = sqlconn.CreateCommand

                sqlsettings.CommandText = "SELECT  [Customers].CustomerName,[FieldName],[FieldData],[SPlineNum],[SPPositionNum],[SPFieldWidth],[ConvertName] " & _
                "FROM [ConvLookup],[Convertlist],[Customers] " & _
                "where [Convertlist].ConvertName = '" & cbConvList.Text & "' " & _
                "and CustomerName = '" & cbCustomers.Text & "'and Convertlist.ID = ConvLookup.ConvertID order by [fieldName] asc"
                Dim lineNum As String = ""
                Dim PosNum As String = ""
                Dim FWidth As String = ""
                Dim Fdata As String = ""
                Dim RowCounter As Integer = 0

                
                AutoAddRow = False

                Dim sqldr4 As SqlDataReader = sqlsettings.ExecuteReader
                While sqldr4.Read
                    'If RowCounter = 0 Then

                    'End If

                    lineNum = sqldr4.Item("SPlineNum".ToString)
                    PosNum = sqldr4.Item("SPPositionNum".ToString)
                    FWidth = sqldr4.Item("SPFieldWidth".ToString)
                    Fdata = sqldr4.Item("FieldData".ToString)

                    'DG.Rows.Add(lineNum.ToString, PosNum.ToString, FWidth.ToString, Fdata.ToString)
                    DG.Rows(RowCounter).Cells(0).Value = lineNum
                    DG.Rows(RowCounter).Cells(1).Value = PosNum
                    DG.Rows(RowCounter).Cells(2).Value = FWidth
                    DG.Rows(RowCounter).Cells(3).Value = Fdata

                    RowCounter += 1

                End While
                sqldr4.Close()
                AutoAddRow = True
            End If
        Catch ex As Exception
            MsgBox("Error " & vbCrLf & rn & ex.Message)
        End Try
The sql returns the values but I get an error

"System.ArguementException DataGridViewComboBoxCell value not valid"

Any help ywould be greatfully recieved.

thanks