Avatar of Southern_Gentleman
Southern_Gentleman
Flag for United States of America asked on

Highlight asp.net gridview cell from pivot query

I created pivot query to be displayed in a gridview. I'm used Devexpress to create the Gridview and was able to simply use the HtmlDataCellPrepared to show anything that was zeroed out. But now I want to use a row value in the part number column and highlight the adjacent cell under Medium column. I tried to use the RowDataBound but nothing shows up in my query.
Here is a sample of what i'm looking for. If I wanted the Medium cell for only part number ABC-1243 I want that cell highlighted regardless of the value in the size columns
Gridview.JPG
Here's the code that - I have no errors but nothing shows up:
Sub gridStock_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
        If e.Row.RowType = DataControlRowType.DataRow Then
            If e.Row.Cells(1).Text = "ABC-123" Then
                e.Row.Cells(6).BackColor = System.Drawing.Color.Red
            End If
        End If
    End Sub

Open in new window

Visual Basic.NETASP.NET

Avatar of undefined
Last Comment
Southern_Gentleman

8/22/2022 - Mon
Mrunal

Hi
Please you try same logic inside of RowCreated event instead of RowDataBound.
Southern_Gentleman

ASKER
Still no difference. I tried all the cell numbers to make sure I was in the correct column. nothing is displaying. grid view is showing but nothing else.
Mrunal

hi,
are you sure you are getting correct value in -
e.Row.Cells(1).Text ?

Debug this line check if values of both the sides are coming properly.

Hope this helps you.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Southern_Gentleman

ASKER
I did debug it and there were no errors. I changed the code a little and Now I am getting a "Specified argument was out of the range of valid values. Parameter name: index" error. There error is on line 640:

Line 638:        Dim name As String = e.GetValue("CorePN").ToStr<wbr ></wbr>ing()
Line 639:        If name = "CIT-88D-2015A" Then
Line 640:            e.Row.Cells(10).BackColor = System.Drawing.Color.Red
Line 641:        End If
Line 642:    End Sub

Open in new window



Is there a row check that I have to use?
ASKER CERTIFIED SOLUTION
Mrunal

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Southern_Gentleman

ASKER
Thanks again. seemed to work.