C# GetCellValue not working

I have a data grid that I am trying to change the color of a row if a column in the grid has a particular value.  In the code below the YELLOW and PURPLE seem to work but I can't get the BLUE to work.....Now I know the obvious answer is that there must be no BLUE values in that column.  Even when I update table set tirhicolr ="BLUE".   I still get no BLUE rows.

Any suggestion on how to troubleshoot this or is there something wrong in my code?

Thanks for your help in advance.
void ptinventUltraGrid_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
        {



//setting cell colors

            if (e.Row.GetCellValue(e.Row.Band.Columns["tirhicolor"]).ToString() == "YELLOW")
            {
                e.Row.Appearance.BackColor = System.Drawing.Color.Yellow;
            }
            if (e.Row.GetCellValue(e.Row.Band.Columns["tirhicolor"]).ToString() == "BLUE")
            {
                e.Row.Appearance.BackColor = System.Drawing.Color.AliceBlue;
            }
            if (e.Row.GetCellValue(e.Row.Band.Columns["tirhicolor"]).ToString() == "PURPLE")
            {
                e.Row.Appearance.BackColor = System.Drawing.Color.Purple;
            }
            if (e.Row.GetCellValue(e.Row.Band.Columns["tirhicolor"]).ToString() == "AQUA")
            {
                e.Row.Appearance.BackColor = System.Drawing.Color.Aqua;

            }
            if (e.Row.GetCellValue(e.Row.Band.Columns["tirhicolor"]).ToString() == "GREEN")
            {
                e.Row.Appearance.BackColor = System.Drawing.Color.Green;

            }

            if (e.Row.GetCellValue(e.Row.Band.Columns["tirhicolor"]).ToString() == "ORANGE")
            {
                e.Row.Appearance.BackColor = System.Drawing.Color.Orange;
            }
            if (e.Row.GetCellValue(e.Row.Band.Columns["tirhicolor"]).ToString() == "NONE")
            {
                e.Row.Appearance.BackColor = System.Drawing.Color.White;
            }

            if (e.Row.GetCellValue(e.Row.Band.Columns["tirhicolor"]).ToString() == "")
            {
                e.Row.Appearance.BackColor = System.Drawing.Color.White;

            }
            if (e.Row.GetCellValue(e.Row.Band.Columns["tirhicolor"]).ToString() == null)
            {
                e.Row.Appearance.BackColor = System.Drawing.Color.White;

Open in new window

BBQMemphisAsked:
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.

Miguel OzSoftware EngineerCommented:
Try:
string targetValue = e.Row.GetCellValue(e.Row.Band.Columns["tirhicolor"]).ToString();
Debug.WriteLine("My target color is: " + targetValue);
// then your code

Also try to use targetValue (to avoid calculating this value all over again - more efficient)  and else if constructs instead of just if: (eg. the first 3 if)
           if (targetValue  == "YELLOW")
            {
                e.Row.Appearance.BackColor = System.Drawing.Color.Yellow;
            }
            else if (targetValue == "BLUE")
            {
                e.Row.Appearance.BackColor = System.Drawing.Color.AliceBlue;
            }
            else if (targetValue  == "PURPLE")
            {
                e.Row.Appearance.BackColor = System.Drawing.Color.Purple;
            }
  // continue with elseif or else



0
käµfm³d 👽Commented:
Which browser are you checking in? I know that when I was trying to get a row color to work I ended up up having to set the color for each cell in the row. The row color would work in FF, but not in IE (or maybe vice versa, I can't remember--but it worked in one and not the other)
0
BBQMemphisAuthor Commented:
thanks for your help.  1) kaufmed this is a windows form

2)  mas_oz2003 - I took your suggestion and even added this

 MessageBox.Show(targetValue);

Ran the form and I get BLUE in the message box but no blue on the form.  

i even changed some of date from YELLOW to BLUE and the old one that was a yellow now displays as White not BLUE.   I am at a loss with this...again thanks
0
Miguel OzSoftware EngineerCommented:
I am wodnring if you have a hidden ccharacter somewhere. Please replace:
 else if (targetValue == "BLUE")
with
 else if (targetValue.Contains("BLUE"))
   {
                e.Row.Appearance.BackColor = System.Drawing.Color.AliceBlue;  //Put a breakpoint here
    }

If you get the breakpoint then your logic is right but if the colour does not change then AliceBlue is not supported as BackColor.
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
BBQMemphisAuthor Commented:
thanks .....CONTAINS resolved the issue.  
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
C#

From novice to tech pro — start learning today.