[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

Setting Conditional color in datagrid control

Tom Youngquist

1/14/2003 12:02:00 AM

Does anyone know how if there is a format for numbers
displayed in a datagrid which would change the color ofthe
value when negative? It seems the {0:0.00%;(0.00%)} works
for putting () around the negative but I can't figure out
how to make it red. {0:0.00%;[red](0.00%)} simply puts
the word [red] in front of the value. Any ideas? Thanks
in advance.
Tom Youngquist
Tom_Y@ix.netcom.com
2 Answers

jjardine

1/14/2003 8:12:00 PM

0

Try doing something like this possibly



'Use this event to check the Flag. If it is true then Make the row Bold.

Private Sub dgCreditHistory_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgCreditHistory.ItemCreated

If e.Item.DataItem Is Nothing Then

Exit Sub

End If

'Get the value of the SelfReported Data and if it is yes then we want to
make that row bold.

Dim strTemp As String = DataBinder.Eval(e.Item.DataItem,
"fieldtolookat").ToString()

If strTemp = "Y" Then

e.Item.Font.Bold = True

End If

End Sub

"Tom Youngquist" <Tom_Y@ix.netcom.com> wrote in message
news:3e8701c2bb57$d74aaf20$d6f82ecf@TK2MSFTNGXA13...
> Does anyone know how if there is a format for numbers
> displayed in a datagrid which would change the color ofthe
> value when negative? It seems the {0:0.00%;(0.00%)} works
> for putting () around the negative but I can't figure out
> how to make it red. {0:0.00%;[red](0.00%)} simply puts
> the word [red] in front of the value. Any ideas? Thanks
> in advance.
> Tom Youngquist
> Tom_Y@ix.netcom.com


Tom Youngquist

1/14/2003 10:11:00 PM

0

Thank you for the suggestion. A variation on this method
worked. I appreciate the help.
>-----Original Message-----
>Try doing something like this possibly
>
>
>
>'Use this event to check the Flag. If it is true then
Make the row Bold.
>
>Private Sub dgCreditHistory_ItemCreated(ByVal sender As
Object, ByVal e As
>System.Web.UI.WebControls.DataGridItemEventArgs) Handles
>dgCreditHistory.ItemCreated
>
>If e.Item.DataItem Is Nothing Then
>
>Exit Sub
>
>End If
>
>'Get the value of the SelfReported Data and if it is yes
then we want to
>make that row bold.
>
>Dim strTemp As String = DataBinder.Eval(e.Item.DataItem,
>"fieldtolookat").ToString()
>
>If strTemp = "Y" Then
>
>e.Item.Font.Bold = True
>
>End If
>
>End Sub
>
>"Tom Youngquist" <Tom_Y@ix.netcom.com> wrote in message
>news:3e8701c2bb57$d74aaf20$d6f82ecf@TK2MSFTNGXA13...
>> Does anyone know how if there is a format for numbers
>> displayed in a datagrid which would change the color
ofthe
>> value when negative? It seems the {0:0.00%;(0.00%)}
works
>> for putting () around the negative but I can't figure
out
>> how to make it red. {0:0.00%;[red](0.00%)} simply puts
>> the word [red] in front of the value. Any ideas?
Thanks
>> in advance.
>> Tom Youngquist
>> Tom_Y@ix.netcom.com
>
>
>.
>