首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >asp .net RowDataBound RSS

asp .net RowDataBound RSS
EN

Stack Overflow用户
提问于 2014-10-31 20:22:56
回答 1查看 48关注 0票数 1

我想要一个RowDataBound,如果之前在文件中登记的日期没有被发现是红色的

例如未找到日期10/10/2014,因此10/11/214为红色,如何将日期编辑为dd/mm/yyyy

谢谢你的帮助。

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2014-11-01 14:28:17

代码语言:javascript
复制
    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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26674620

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档