Reputation: 185
Afternoon All,
I have been searching the net for some help in reference to applying some conditional formatting based on a value in my grid view. I am using Studio 2010 in the form of VB.
I essentially have a gridview and want to highlight a row of data green when the 'Status' for items in my gridview are'On-Line'.
I have been been reviewing a solution here.
I believe this solution may work but i still get an error (Blue line) under the e.Row when i apply this to my code. This simply states that 'Row' is not a member of System.EventArgs.
I have already added Imports System.Web.UI.WebControls.GridViewRow
to the top of my web page and i still have no joy.
Please find below my code. If someone could review this and let me know what the issue is i would be most greatful.
Imports Microsoft.VisualBasic
Imports System.Configuration
Imports System.Web.UI.WebControls.GridViewRow
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub grdCriticalSystems_DataBound(sender As Object, e As System.EventArgs) Handles grdCriticalSystems.DataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If DataBinder.Eval(e.Row.DataItem, "Status").ToString() = "On-Line" Then
e.Row.BackColour = System.Drawing.Color.Green
End If
End If
End Sub
End Class
Many thanks is advance for any help.
Regards Betty
Upvotes: 1
Views: 1839
Reputation: 185
Afternoon All,
I have managed to complete the above by amndeding the code to the following...
Protected Sub grdCriticalSystems_DataBound(sender As Object, e As GridViewRowEventArgs) Handles grdCriticalSystems.DataBound
I needed to replace system.EventArgs with GridViewRowEventArgs. this has now worked a treat.
Betty
Upvotes: 1