Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 291
  • Last Modified:

ItemDataBound

Hi,

I am trying to put differnt colors for datagrid rows based item dispalyed. I can get colors different colors but the problem is:

Suppose I have and item named "Abc", here I get specified color for some of the "Abc" but not all. If I specifiy all other items one color, I get some of the Other items the specified color but not all.

       Select Case e.Item.ItemType
            Case ListItemType.Item
                Dim lstSys As String = CType(e.Item.FindControl("lblSysName"), Label).Text

                Select Case lstSys
                    Case "Abc"
                        e.Item.BackColor = Drawing.Color.Red.LightYellow
                    Case Else
                        e.Item.BackColor = Drawing.Color.Red.LimeGreen
                End Select

                'If lstSys = "Abc" Then
                '    e.Item.BackColor = Drawing.Color.Red.LightYellow
                'Else
                '    e.Item.BackColor = Drawing.Color.Red.Silver
                'End If
        End Select

I tried both If and case conditions but the result is same. could anyone pls find what's wrong?

aYHA
0
ayha1999
Asked:
ayha1999
1 Solution
 
b1xml2Commented:
Would the following help?

Select Case e.Item.ItemType
            Case ListItemType.Item, ListItemType.AlternatingItem
                Dim lstSys As String = CType(e.Item.FindControl("lblSysName"), Label).Text

                Select Case lstSys
                    Case "Abc"
                        e.Item.BackColor = Drawing.Color.Red.LightYellow
                    Case Else
                        e.Item.BackColor = Drawing.Color.Red.LimeGreen
                End Select

                'If lstSys = "Abc" Then
                '    e.Item.BackColor = Drawing.Color.Red.LightYellow
                'Else
                '    e.Item.BackColor = Drawing.Color.Red.Silver
                'End If
        End Select
0
 
Hamed ZaghaghiProgrammerCommented:
you must check for both ListItemType.Item and ListItemType.AlternatingItem;
0
 
ayha1999Author Commented:
Hi,

I know the problem and I tried to solve like ...

Case ListItemType.Item Or ListItemType.AlternatingItem

but It didn't work.

Now the following is working.

Case ListItemType.Item, ListItemType.AlternatingItem

thanks for the help

ayha
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now