0

我目前在 ASP.NET VB 中有一个 Gridview,您可以在其中选择一行,然后将数据传输到下一页以供输入。我的问题是有一种简单的方法可以在某人在同一天输入该行的信息后突出显示该行。因此,如果有人今天为某人输入数据,那么明天突出显示将在下一个日历日消失。我很感激任何帮助。

这是我目前拥有的。

    Public Sub Get_GV()
    ' Fills Gridview with data selected from dropdown-area

    DSADT.SelectParameters("Area").DefaultValue = DDArea.SelectedValue
    Dim dv As DataView = DSconnect.Select(DataSourceSelectArguments.Empty)
    GridView1.DataSource = dv
    GridView1.DataBind()

End Sub

Private Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated

    ' Allows you to "select"/Highlight a row without a select button
    If e.Row.RowType = DataControlRowType.DataRow Then
        e.Row.Attributes("onmouseover") = "this.style.cursor='pointer';this.style.backgroundColor = '#87CEFF';"
        e.Row.Attributes("onmouseout") = "this.style.textDecoration='none';this.style.backgroundColor = '#FFFFFF';"
        e.Row.Attributes("OnClick") = Me.Page.ClientScript.GetPostBackClientHyperlink(Me.GridView1, "Select$" & e.Row.RowIndex)
    End If

End Sub


Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
    Dim sb As New System.Text.StringBuilder()

    'Submits data to next page
    Response.Redirect("RoundingEntry.aspx?Room=" & GridView1.SelectedRow.Cells(1).Text & "&Name=" & GridView1.SelectedRow.Cells(2).Text & "&Rounder=" & DDRounder.SelectedValue & "&Area=" & DDArea.SelectedValue)

End Sub
4

2 回答 2

0

您需要在查询返回的数据中包含上次修改日期以绑定网格视图,然后您可以处理该RowDataBound事件以根据今天的日期检查每行的上次修改日期,如下所示:

代码隐藏:

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
    ' Only check the last modified date for data rows, ignore header and footer rows
    If e.Row.RowType = DataControlRowType.DataRow Then
        ' Get the last modified date for each row, possibly in a hidden field control and compare it to today's date

    End If
End Sub

标记:

<asp:gridview id="GridView1" 
    onrowdatabound="GridView1_RowDataBound" 
    runat="server">
  </asp:gridview>

onrowdatabound="CustomersGridView_RowDataBound" 
于 2013-10-10T18:49:54.930 回答
0

你可以使用这样的东西:

Private Sub FormatMyGridView _
               (ByVal sender As Object, _
                ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) _
           Handles GridView1.RowDataBound

      Dim drItems As DataRow

         If e.Row.RowType = DataControlRowType.DataRow Then

         drRequest =DirectCast(e.Row.DataItem, System.Data.DataRowView).Row

         ' get your field from DataItem
         ' format the row based on field value:
         if drItems.YourFieldDateTime.Date = DateTime.Date

           ' hilight the row

           e.Row.BackColor = System.Drawing.Color.Red;

       End If    

   End Sub
于 2013-10-10T18:46:15.853 回答