I have a gridview with contractid as one column. what I would like to do here is that if the all the first contract id are the same I want to use grey as a background and when the next contid are the same I want white back ground and when the next contract id the same I want to use grey again ......How can I do this. thank you for the help.
Inherits System.Web.UI.Page
Dim prevID As String, currID As String
Protected Sub gvTabulation_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvTabulation.RowDataBound
lblView.Visible = True
lblView.Text = String.Format("You are viewing page {0} of {1} ", gvTabulation.PageIndex + 1, gvTabulation.PageCount)
currID = e.Row.Cells(0).Text
If e.Row.RowType = DataControlRowType.DataRow Then
If prevID <> currID Then
prevID = currID
Dim newColor As String = "white"
e.Row.BackColor = System.Drawing.Color.FromName(newColor)
Else
Dim newColor As String = "Yellow"
e.Row.BackColor = System.Drawing.Color.FromName(newColor)
End If
End If
End Sub
Inherits System.Web.UI.Page
Dim prevID As String, currID As String
Protected Sub gvTabulation_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvTabulation.RowDataBound
lblView.Visible = True
lblView.Text = String.Format("You are viewing page {0} of {1} ", gvTabulation.PageIndex + 1, gvTabulation.PageCount)
currID = e.Row.Cells(0).Text
If e.Row.RowType = DataControlRowType.DataRow Then
If prevID <> currID Then
prevID = currID
Dim newColor As String = "white"
e.Row.BackColor = System.Drawing.Color.FromName(newColor)
Else
Dim newColor As String = "Yellow"
e.Row.BackColor = System.Drawing.Color.FromName(newColor)
End If
End If
End Sub