Please refer this code.
HTML
<asp:GridView ID="GridView1" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White"
OnRowDataBound="GridView1_OnRowDataBound" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="30" />
<asp:BoundField DataField="CheckIn" HeaderText="CheckIn DateTime" DataFormatString="{0:dd/MM/yyyy}"
ItemStyle-Width="150" />
</Columns>
</asp:GridView>
VB.Net
I have changed the If condition in RowDataBound event.
Protected Sub GridView1_OnRowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowIndex <> 0 Then
Dim dt1 As DateTime = Convert.ToDateTime(Me.GridView1.Rows(e.Row.RowIndex - 1).Cells(1).Text, New CultureInfo("en-GB"))
Dim dt2 As DateTime = Convert.ToDateTime(e.Row.Cells(1).Text, New CultureInfo("en-GB"))
Dim timeSpan As TimeSpan = dt2.Subtract(dt1)
If timeSpan.TotalDays >= 2 Then
e.Row.BackColor = Color.Red
End If
End If
End If
End Sub
You need to use this format to display the date in dd/MM/yyyy hh:mm AM or PM format.
<asp:BoundField DataField="CheckIn" HeaderText="CheckIn DateTime" DataFormatString="{0:dd/MM/yyyy}"
ItemStyle-Width="150" />