How to display with different font color

A

ad

I use a dataGrid to list the scores of students.
If the score is less than 60, I want the score display with font of red.
The other will display with blue font.
How can I do that?
 
P

Patrick Olurotimi Ige

Try looking at this at
:-http://authors.aspalliance.com/Colt/SourceCode/HelperFunction.html
That should help you.
Patrick
 
J

Jeebu

hi,
u can use the grid ItemDataBound event for that.

DataGridItem Gridtem = e.Item;
int marks;
DataRowView dataRowView = (DataRowView)e.Item.DataItem;
ListItemType itemType = e.Item.ItemType;
string str = string.empty;
if( itemType==ListItemType.Item || itemType==ListItemType.AlternatingItem )]
{

marks = int.parse(dataRowView.Row["Fieldname"].ToString());

if(marks<60)
{
str += "<font color='red'>" + marks.tostring() + "</font>";

}
else
{
str += "<font color='blue'>" + marks.tostring() + "</font>";

}

Gridtem.cells[specify the cell number of marks].text=str;

}
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top