473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

GridView Column Color Change

I have a GridView that is using an ObjectDataSource to populate.

One of my columns is named "Status" and can have a value of "Complete",
"Error", "Active", and "Unknown". I would like to have the text for the
word "Error" displayed in RED letters. How can I do this with a GridView
control?

Mar 1 '06 #1
3 2982
Hi,

One of the way to Acheive this you have to use the "RowDataBound Event" you
can check if the text of the cell is "Error" and there you can make the
Color of that text to Red.

//If you know the column index , I assume the column is 3 in this sample
code and applied.
if(e.Row.Cells[3].Text=="Error")

{

e.Row.Cells[3].ForeColor = Color.Red;

}

hope that helps

Regards,

A.Sivakumar.
"dm1608" <dm****@spam.net> wrote in message
news:uc**************@TK2MSFTNGP15.phx.gbl...
I have a GridView that is using an ObjectDataSource to populate.

One of my columns is named "Status" and can have a value of "Complete",
"Error", "Active", and "Unknown". I would like to have the text for the
word "Error" displayed in RED letters. How can I do this with a GridView
control?

Mar 1 '06 #2
Thanks --

Does anyone know of a way to do this with hardcoding the column #?

"Siva" <si***@syncfusion.com> wrote in message
news:O4**************@TK2MSFTNGP11.phx.gbl...
Hi,

One of the way to Acheive this you have to use the "RowDataBound Event"
you can check if the text of the cell is "Error" and there you can make
the
Color of that text to Red.

//If you know the column index , I assume the column is 3 in this sample
code and applied.
if(e.Row.Cells[3].Text=="Error")

{

e.Row.Cells[3].ForeColor = Color.Red;

}

hope that helps

Regards,

A.Sivakumar.
"dm1608" <dm****@spam.net> wrote in message
news:uc**************@TK2MSFTNGP15.phx.gbl...
I have a GridView that is using an ObjectDataSource to populate.

One of my columns is named "Status" and can have a value of "Complete",
"Error", "Active", and "Unknown". I would like to have the text for the
word "Error" displayed in RED letters. How can I do this with a GridView
control?


Mar 1 '06 #3
Hi ,
I am a begginer to ASp.Net ,so there should be some easy way for this i am
not sure.

I guess you can use templates for this( i dont have a full code now reg
this) ,
something like this.
SomeList = (Label) e.Item.FindControl("lblsomeID");
assuming a label is kept in that template"
and changing thats templates label color can provide the same result.

Regards,
Hari
Mar 1 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
4
by: Nalaka | last post by:
Hi, I have two questions about gridViews. 1. How can I intercept the row/column values at loading to change values? 2. After I update a row (using default update functionality), how can I...
5
by: yefei | last post by:
In my web design, I display records from a SQL DataBase according to some filters the GridView is defined with select commands and selest parameters however, I also want to display all records...
3
by: Rob Roberts | last post by:
Is there any way to add attributes to GridView ButtonFields? I'm looking for a way to add event handlers to ButtonFields. With regular ASP.NET buttons, I can add event handlers by using the...
3
by: jhaidon | last post by:
Hi everybody, I want to fill in a GridView with a dataset. So I created the list of fields that I want to see in the gridview. And I added a column (in first position in the gridview) as a...
1
by: martin1 | last post by:
Hi, All, Anyone knows how to change gridview text info? specifically the gridview populate from sql db, first column is string rather than number, i want to change first row in first column into...
2
by: Loading name... | last post by:
Hey asp.net 2.0 I have a GridView on my webpage. This GridView's datasource is a SqlDataSource. The SqlDataSource returns 3 columns. Here is my problem: My GridView consist of 3 columns...
0
by: landesjoe | last post by:
Hi, here's my problem in short: Text boxes in gridview don't seem to hold their value if the column's .Visible property is changed back and forth. I've got a form with a gridview populated from...
4
by: Yin99 | last post by:
I have a Gridview binding to a DataTable source. I'd like to set the column with of the second column. I cannot do this apparently because when AutoGenerateColumns=true, they do not appear in the...
1
by: olgagjor | last post by:
how can i change column in gridview with css in visual studio 2005. my table has 5 rows and 4 columns.if i want to change 3 rd column can i change entire column or i must change separately. because i...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.