473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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
Nov 16 '05 #1
2 1320
I'm not to terribly good with this yet but I was just messing with text
validation and I would assume that you could use this same methodology to
change the color of text rather then create alert messages etc (maybe you
want to do both, who knows?). Check out this link and it should help you with
your validating:

http://msdn.microsoft.com/vcsharp/de...ms03162004.asp

"Raul M. Colon" wrote:
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

Nov 16 '05 #2
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

"Raul M. Colon" <Ra********@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
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

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jason Gleason | last post by:
I have a question about the asp.net datagrid in c#. i have the following grid... <asp:datagrid id="RosterList" runat="server" Font-Names="Verdana" BorderColor="Black" GridLines="Vertical"...
0
by: Sreejumon[MVP] | last post by:
Hi, Here you go -> Right clikc the datagrid -> Property builder -> format-> header Then set the fontcolor and back color. regadrs
0
by: Amber | last post by:
There are times when you will need to highlight or otherwise modify the contents of a particular DataGrid row-column value based upon the value in the column. In this example we will select the...
1
by: Blaine | last post by:
Pulling my hair out here! I have a datagrid with a number of bound columns (NOT template columns). When choosing to Edit, the textboxes appear, but the font is not the same as the original text...
0
by: csgraham74 | last post by:
Hi there, i have creted a datagrid control to display images using the following code. <asp:DataGrid id="dg_Properties" runat="server" HorizontalAlign="Center" Width="450px"...
2
by: Tor Inge Rislaa | last post by:
How to change row height in a DataGrid I have DataGrid that is filled with data from a table in a DataSet. The content of the cells is text of more than one line (as a note field). What I...
5
by: Earl | last post by:
I want to fire a database update off of a single change to a single cell in the datagrid. This apparently cannot be done using keypress, keyup, keydown, etc. I've read George Shepard's FAQ and...
0
by: Shell | last post by:
Hi All, I am using ASP.NET 2.0 Themes for applying styles to DataGrid, where I have the following definition: <asp:DataGrid runat="server" Font-Name="Verdana" ForeColor="Blue" Font-Size="6px"...
3
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.