troubleshooting Question

Change the foreground color of grid row based on value for another column

Avatar of countrymeister
countrymeister asked on
ASP.NET.NET ProgrammingVisual Basic.NET
9 Comments2 Solutions934 ViewsLast Modified:
I have a GridView with fthree columns
ColumnType (visible = false)
Description (visible = false)

Of the three columns that I display on a page only the Checbox column is displayed and  the Description is used as the Text for the Checkbox colum.

I want to change the foreground color of the text based on the value of the ColumnType.
ColumnType holds value 0,1,2.

so I want to create a Eval for ForeColor
 ForeColor='<%# Eval("If(ColumnType=0) Then "Green" ElseIf(ColumnType=1) Then "Blue" Else "Black" ) %>'

<asp:TemplateField ItemStyle-Width="100px"  HeaderStyle-Width="100px"  >
                                          <asp:CheckBox ID="itemSelect" runat="server" ItemStyle-Width="100px"  HeaderStyle-Width="100px"   font-size = "11px"   AutoPostBack="false"   Text='<%# Eval("Description") %>'   />
Kamal Khaleefa
Information Security Specialist

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros