| | |
Adding color to GridView
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
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
From Time Enough for Love by Robert A. Heinlein
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
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
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!!!
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
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
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
![]() |
Similar Threads
- Regular Expressions (C#)
- high school student needs help!!! please help!! (Website Reviews)
Other Threads in the ASP.NET Forum
- Previous Thread: Need Stored Procedure "sp_ValidateUser" for Login Page
- Next Thread: Building an Excel like Application
| Thread Tools | Search this Thread |
.net activexcontrol advice ajax alltypeofvideos appliances asp asp.net bc30451 beginner bottomasp.net box browser button c# c#gridviewcolumn cac checkbox click commonfunctions confirmationcodegeneration content courier css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock development dgv dialog dropdownlist dynamically edit expose fileuploader fill flash formatdecimal forms formview gridview gudi homeedition iframe iis javascript jquery listbox login microsoft mono mouse mssql multistepregistration news numerical objects opera panelmasterpagebuttoncontrols radio redirect registration relationaldatabases reportemail rotatepage save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 suse textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visualstudio web webapplications webdevelopemnt webprogramming webservice xml xsl youareanotmemberofthedebuggerusers





