GridView Column Color Change

  • Thread starter Thread starter dm1608
  • Start date Start date
D

dm1608

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?
 
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.
 
Thanks --

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



Siva said:
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 said:
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?
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top