[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Put a Gridview row in a specific color.

Posted on 2007-03-23
9
Medium Priority
?
281 Views
Last Modified: 2011-09-20
I'm using Visual Studio 2005, but programing in Visual Basic I want to know what code implement in RowDataBound Procedure to put an specific row in a different color when a cell in that row has an specific value.
Let say that my grid has the name of "GrdBrokers" and I want to put the entire row in red color when the cell # 5 has the value of "DELETED"
0
Comment
Question by:NeGueSa
[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
  • 4
  • 3
  • 2
9 Comments
 
LVL 12

Expert Comment

by:craskin
ID: 18780849
This doesn't have to be in the rowdatabound procedure, but in any case,

For each row as GridViewRow in GridView1.Rows
    If row.Cells(the cell number of that column).Text = "DELETED" Then
            row.BackColor = Drawing.Color.Red
    End If
Next
0
 

Author Comment

by:NeGueSa
ID: 18781142
That's work with backcolor, but what about forecolor, it doen't work for forecolor
0
 
LVL 28

Expert Comment

by:iboutchkine
ID: 18781221
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
          If e.Row.Cells(5).Text = "DELETED" then
                e.Row.ForeColor = Drawing.Color.LightGreen
         End if
        End If

    End Sub
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:NeGueSa
ID: 18781260
I already test this string and is strange for Font Bold works, but for Forecolor NOT
            If e.Row.Cells(7).Text = "DELETED" Then
                e.Row.Font.Bold = True
                e.Row.ForeColor = Drawing.Color.Red
            End If
0
 
LVL 12

Expert Comment

by:craskin
ID: 18781791
try e.row.color
0
 
LVL 28

Accepted Solution

by:
iboutchkine earned 1500 total points
ID: 18781881
check if you have any CSS attached to the grid
0
 

Author Comment

by:NeGueSa
ID: 18782060
e.row.color doesn't exist as option, by other hand,  iboutchkine good point, no I don't have any CSS attached, but what I have is this which probably doesn't allow me to change the forecolor, bt I can't get rid of this:

      function hight_temp(vl,vlw){
      
              if(xState){               
          if( xState.parentElement.parentElement != vl) {    
 
          if (  vlw == 1 ){        
            fmr_cl = vl.style.backgroundColor    
            vl.style.backgroundColor='#639ABC';          
            vl.style.color='white';
           
           }
           else{          
                                 
            vl.style.backgroundColor= fmr_cl ;          
            vl.style.color='black';
           
             }          
           }
           
           }else{
           
           
          if (  vlw == 1 ){
         
            fmr_cl = vl.style.backgroundColor                          
            vl.style.backgroundColor='#639ABC';          
            vl.style.color='white';
           }
           else{                                  
            vl.style.backgroundColor= fmr_cl;          
            vl.style.color='black';
           }  
           
           
           
           
           }
           }
          // -->
This function highlight the grid when you point it
0
 
LVL 28

Expert Comment

by:iboutchkine
ID: 18782091
Try to get rid of CSS and then try ForeColor. It must work. It works in my case
0
 

Author Comment

by:NeGueSa
ID: 18782521
As I told you iboutchkine is not a CSS is a java function which allow me to highlight each grid row when I point them, and I can not get rid of it, anyway you were the guy who was closer to the "solution" I will give the points.
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

650 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