1

如果未找到归档签入中的上一个日期是红色,我想要一个 RowDataBound

就像找不到日期 10/10/2014 所以 10/11/214 是红色的,我如何将日期编辑为 dd/mm/yyyy

谢谢你的帮助 。

Name        Checkin           Checkout              Branch
450 10/6/2014 9:13:38 AM    10/6/2014 6:01:50 PM    branch0
450 10/7/2014 9:16:34 AM    10/7/2014 6:44:21 PM    branch0
450 10/8/2014 9:11:53 AM                            branch0
450 10/8/2014 6:03:25 PM                            branch0
450 10/11/2014 9:17:33 AM   10/11/2014 6:29:16 PM   branch0 (red color )
450 10/11/2014 4:50:42 PM                           branch0
450 10/12/2014 9:09:38 AM                           branch0
4

1 回答 1

0
    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView1.RowDataBound
        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.TotalHours > 24 Then
                    e.Row.BackColor = Color.Red
                End If
            End If
        End If

End Sub
于 2014-11-01T06:28:16.693 回答