Is there a way to change the font or color of a DataGrid single li

G

Guest

In my web application the user need a visual indication when an item of a
DataGrid meets some condition. Is there a way to change the font or the
forecolor of the text of DataGrid lines that meet some condition? (Something
like the Conditional Formatting of Excel)

Thanks!

Raul
 
E

Emre Guldogan

Raul:

in your aspx in related tag;
TheAttributeYouWantToModify='<%# GetVisualIndication(
DataBinder.Eval(Container.DataItem, "VisualFormatter") ) %>'

The function GetVisualIndication() is a function in your codebehind file
which performs necessary filtering for the visualisation, such as;

protected string GetVisualIndication( object yourField )
{
//cast the field into its type and make your decision
//and return the attribute
}

OR, you can directly get the attribute without any decision, I mean you can
decide the attribute
in your query string (may be with a case-when-then). Then, you can format
the field without the necessity of a filtering function. e.g:

TheAttributeYouWantToModify='<%# DataBinder.Eval(Container.DataItem,
"VisualFormatter") %>'

But, sometimes it may be a mandatory using a function for such situations.
It changes according to your design... I hope this is an answer for your
question
 

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

Top