473,769 Members | 4,173 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GridView Column Color Change

I have a GridView that is using an ObjectDataSourc e 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 3010
Hi,

One of the way to Acheive this you have to use the "RowDataBou nd 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.ne t> wrote in message
news:uc******** ******@TK2MSFTN GP15.phx.gbl...
I have a GridView that is using an ObjectDataSourc e 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***@syncfusi on.com> wrote in message
news:O4******** ******@TK2MSFTN GP11.phx.gbl...
Hi,

One of the way to Acheive this you have to use the "RowDataBou nd 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.ne t> wrote in message
news:uc******** ******@TK2MSFTN GP15.phx.gbl...
I have a GridView that is using an ObjectDataSourc e 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.FindCont rol("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
5041
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 select, remember it, and then use it in the update. It works just fine when I have full control of the whole process. I want to do the same for my GridView/SqlDataSource combinations. I typically select from a view and update the corresponding...
4
2616
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 re-format the updated row fields. I have looked at gridView.rowUpdated method, but cannot figure out how....
5
3377
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 in the database when the user press a "View All" button. In this case, I need to change the select comand and clear the parameters. And I did this in the button_click() event. the GridView can display desired results when I press the "View All"...
3
14338
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 Attributes collection, like this: MyButton.Attributes.Add("onmouseover", "this.className='actionH'"); MyButton.Attributes.Add("onmouseout", "this.className='actionN'"); But the GridView ButtonField doesn't seem to have an Attributes property. Is...
3
5851
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 ButtonField column (ButtonType: button). My records are loaded correctly. During the RowDataBound event, I tried to change the Text of the button for some records (depends of a check on others cells).
1
1831
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 another string, for example "Book" , but I don't want this chnage to affect database. Thanks
2
429
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 (id column + 2 text columns). I want to hide the id column, and change the formating of the text columns. I've tryed
0
2437
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 a data view (which in turn is loaded from a manually setup DataTable for testing purposes). One of the columns in the grid is a checkbox that's tied to an event handler that'll change the .Visible property of a column with a text box. That text...
4
25536
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 columns collection. I modified the RowCreated even to gridview, and I can change properties on the cells, but not width. (setting tooltip, background color, etc, all work but changing width has no effect). Here's sample code I am using:
1
4506
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 want to create class for properties for the column. did i have to put class in every <td class =""> for that column or i can change entire column.
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7409
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5299
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3959
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.