How do I format a negative number during in the Eval

S

ssmith

I am trying to format a negative value with parentheses during the
databinding process in the code behind. Here is an example of what I have
tried:

<asp:Label ID="lblAmount" runat="server" Text='<%# Eval("TotalAmount",
"{0:N0; (0:N0)}") %>'></asp:Label>

I was hoping the second part would place the parentheses around a negative
number. Any suggestions? Thanks!
 
N

Nathan Sokalski

Take a look at the following:

ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_fxfund/html/6f74fd32-6c6b-48ed-8241-3c2b86dea5f4.htm

There are three general formats which are as follows:

<formatstringforallvalues>
<positivenumberformatstring>;<negativenumberformatstring>
<positivenumberformatstring>;<negativenumberformatstring>;<zerovalueformatstring>

Good Luck!
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top