2014-10-31 1 views
1

발견되지 제기 검사에서 이전 날짜가 너무 10/11/214가 빨간색으로 어떻게 할 수없는 일 2014년 10월 10일처럼 붉은 색ASP .NET RowDataBound RSS

될 경우 나는 RowDataBound을 원하는 나는 날짜를 편집하여 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 

답변

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