I am pulling three coloums of data from a SQL view into my data drid Day,TimeIn,Timeout
I want to colour my datagrid rows red if timeout is null and green if both the timein, timeout have data in them.

here is my code so far, but it aint working

     Public Sub Datagridcolours()
    'Sets datagrid row colours  
    Dim cell As DataGridViewCell
    Dim CellVar As String
    For Each row As DataGridViewRow In Me.DGVClockins.Rows

        Dim x As String = row.Cells("ClockOUT").ToString
        cell = row.Cells("CLOCKOUT")
        CellVar = row.Cells("ClockOUT").ToString

        Select Case x

            Case IsDBNull(x)
                cell.Style.BackColor = Color.Red
                cell.Style.ForeColor = Color.White
        End Select

End Sub

hope someone out there can help me.
thanks in advance.

This is the code you need:

   For Each row As DataGridViewRow In dataGridView1.Rows
    Dim timeOut As Object = dataGridView1("Timeout", row.Index).Value
    Dim timeIn As Object = dataGridView1("Timein", row.Index).Value
    If timeOut Is Nothing Then
        dataGridView1.Rows(row.Index).DefaultCellStyle.BackColor = Color.Red
    ElseIf timeOut IsNot Nothing AndAlso timeIn IsNot Nothing Then
        dataGridView1.Rows(row.Index).DefaultCellStyle.BackColor = Color.Green
    End If

Hope it will do any good.

thanks for your help, I implimented your code but all the rows are now green.

I wanted all rows that have data in the clockin to be red, and rows that have data in clockin and data in the clockout to be green