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

Southern_GentlemanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MrunalCommented:
Hi
Please you try same logic inside of RowCreated event instead of RowDataBound.
0
Southern_GentlemanAuthor Commented:
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.
0
MrunalCommented:
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.
0
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Southern_GentlemanAuthor Commented:
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?
0
MrunalCommented:
Hi,
" out of the range" error is generally comes when you try to access grid row cell (column) by index.
Best practice is access that cell/column by "column_name".
This will never break.

Can you try this:
http://forums.asp.net/t/1246157.aspx?RowDataBound+refer+to+cells+by+column+name+rather+than+index+
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Southern_GentlemanAuthor Commented:
Thanks again. seemed to work.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.