Adding color to GridView

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2004
Posts: 127
Reputation: johnroach1985 is an unknown quantity at this point 
Solved Threads: 0
johnroach1985's Avatar
johnroach1985 johnroach1985 is offline Offline
Junior Poster

Adding color to GridView

 
0
  #1
Jun 26th, 2007
Hi. I am creating an asp.net web site. Using GridView the website creates a table. Now my question is I want to color the text "NO" red within the table cells. Waiting for your reply.Please keep in mind my code is written in C# so any C# examples would be greatly welcomed...
"By the data to date, there is only one animal in the Galaxy dangerous to man—man himself. So he must supply his own indispensable competition. He has no enemy to help him."
From Time Enough for Love by Robert A. Heinlein
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 5
Reputation: akela_p501usa is an unknown quantity at this point 
Solved Threads: 0
akela_p501usa's Avatar
akela_p501usa akela_p501usa is offline Offline
Newbie Poster

Re: Adding color to GridView

 
0
  #2
Jun 26th, 2007
Examining the GridView's Aesthetic Properties
Like the DataGrid in ASP.NET 1.x, the GridView contains a wealth of properties that can be set to gussy up the appearance of the GridView. Properties such as BackColor, Font, and ForeColor allow you to dictate the aesthetics for the entire GridView. You can also specify aesthetic settings specific to particular parts of the GridView through the HeaderStyle, RowStyle, AlternatingRowStyle, FooterStyle, and other properties. Additionally, styles can be set on a column-by-column basis, as well.

If you are an artistic person you can likely put together proper colors and styles that will provide the end user with an eye-pleasing GridView. If you are like me, though, the good news is that the GridView can be Auto Formatted to a variety of well put together styles. To take advantage of the Auto Formatting, simply click the Auto Format link in the GridView's Smart Tag, which will display the Auto Format dialog box
Last edited by akela_p501usa; Jun 26th, 2007 at 2:36 pm. Reason: mistakes
Chace K. Daggers
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 127
Reputation: johnroach1985 is an unknown quantity at this point 
Solved Threads: 0
johnroach1985's Avatar
johnroach1985 johnroach1985 is offline Offline
Junior Poster

Re: Adding color to GridView

 
0
  #3
Jun 27th, 2007
Thanks. But I only want to color certain words with certain colors. I don't think Auto Format resolves my problem since OK or NO can be anywhere within the table cells. Can this be done with a C#? if so how? Thank you in advance
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 5
Reputation: akela_p501usa is an unknown quantity at this point 
Solved Threads: 0
akela_p501usa's Avatar
akela_p501usa akela_p501usa is offline Offline
Newbie Poster

Re: Adding color to GridView

 
0
  #4
Jun 27th, 2007
I like this link....

http://www.c-sharpcorner.com/UploadF...eGridView.aspx


!!!! Let's hope this resolves your dilemma if that's what it is. Good Luck wityh your project!!!
Chace K. Daggers
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 127
Reputation: johnroach1985 is an unknown quantity at this point 
Solved Threads: 0
johnroach1985's Avatar
johnroach1985 johnroach1985 is offline Offline
Junior Poster

Re: Adding color to GridView

 
0
  #5
Jun 28th, 2007
Thank your for the link. I think I can cook up something with the information you gave me.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 5
Reputation: hemantksh is an unknown quantity at this point 
Solved Threads: 0
hemantksh hemantksh is offline Offline
Newbie Poster

Re: Adding color to GridView

 
0
  #6
Jun 28th, 2007
Use RowDataBound event. Find the control using FindControl. Check the value of the control and depending on the value set the FontColor property.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 95
Reputation: manoshailu is an unknown quantity at this point 
Solved Threads: 9
manoshailu's Avatar
manoshailu manoshailu is offline Offline
Junior Poster in Training

Re: Adding color to GridView

 
2
  #7
Jul 5th, 2007
hi,

u can use below for adding color to gridview

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
int i,j;
string c;

for (i = 0; i <= GridView1.Rows.Count - 1; i++)
{
for (j = 0; j <= GridView1.Rows[i].Cells.Count-1; j++)
{
c = GridView1.Rows[i].Cells[j].Text;
if (c == "NO")
{
//GridView1.Rows[i].Cells[j].BackColor = System.Drawing.Color.Blue;
GridView1.Rows[i].Cells[j].ForeColor = System.Drawing.Color.Blue;
}
else if (c == "OK")
{
//GridView1.Rows[i].Cells[j].BackColor = System.Drawing.Color.Red;
GridView1.Rows[i].Cells[j].ForeColor = System.Drawing.Color.Red;
}
}
int k;
k = GridView1.Columns.Count;
}
}


shailu
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 127
Reputation: johnroach1985 is an unknown quantity at this point 
Solved Threads: 0
johnroach1985's Avatar
johnroach1985 johnroach1985 is offline Offline
Junior Poster

Re: Adding color to GridView

 
0
  #8
Jul 5th, 2007
Thank you so much .... You got my star!!!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC