?
Solved

ItemDataBound

Posted on 2005-04-05
3
Medium Priority
?
282 Views
Last Modified: 2010-04-07
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
Comment
Question by:ayha1999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 23

Accepted Solution

by:
b1xml2 earned 1000 total points
ID: 13708228
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
 
LVL 9

Expert Comment

by:zaghaghi
ID: 13708655
you must check for both ListItemType.Item and ListItemType.AlternatingItem;
0
 
LVL 7

Author Comment

by:ayha1999
ID: 13708768
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

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question