【问题标题】:asp .net RowDataBound RSSasp .net RowDataBound RSS
【发布时间】:2014-10-31 12:22:55
【问题描述】:

如果未找到之前提交的签入日期为红色,我想要一个 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

【问题讨论】:

    标签: asp.net rowdatabound


    【解决方案1】:
        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
    

    【讨论】:

      猜你喜欢
      • 2021-05-06
      • 1970-01-01
      • 2011-05-02
      • 2011-03-02
      • 1970-01-01
      • 1970-01-01
      • 2011-04-08
      • 1970-01-01
      • 2017-03-24
      相关资源
      最近更新 更多