How to display with different font color

  • Thread starter Thread starter ad
  • Start date Start date
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?
 
Try looking at this at
:-http://authors.aspalliance.com/Colt/SourceCode/HelperFunction.html
That should help you.
Patrick
 
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;

}
 
Back
Top