ROBERT MECHLER
asked on
Left aligned $ and right aligned amount ASP.NET
The following code places a $ one space to the left of the dollar amount in a grid cell. The value placed in the Text field is processed using the following code:
The code that needs a String.Format is "$ "
Either left aligned in the cell or padded with spaces to the right of the $ . I tried adding spaces and no changes. I tried using String.Fromat( "{0,-15} ... but no change.
So far none of the samples I've found give me a $ that is left aligned so that they appear on the web page in a grid vertically and left aligned.
<asp:Label runat="server" ID="MaketvalueLabel" Text='<%# String.Format("{0}{1}","$ ",String.Format("{0:n}",Eval("MarketValue"))) %>'
ForeColor='<%# Convert.ToInt32(Eval("MarketValue")) >=0
System.Drawing.Color.Black:System.Drawing.Color.Red%>'>
></asp:Label>
Text='<%# String.Format("{0}{1}","$ ",String.Format("{0:n}",Eval("MarketValue"))) %>'
The code that needs a String.Format is "$ "
Either left aligned in the cell or padded with spaces to the right of the $ . I tried adding spaces and no changes. I tried using String.Fromat( "{0,-15} ... but no change.
So far none of the samples I've found give me a $ that is left aligned so that they appear on the web page in a grid vertically and left aligned.
ASKER
I get something like $ 390,300.33
$ 30.23
$ 23.499.43
I've actually decided to just insert a column into the grid with a value of '$'. Much simpler.
$ 30.23
$ 23.499.43
I've actually decided to just insert a column into the grid with a value of '$'. Much simpler.
add this to label
style="text-align: left;"
style="text-align: left;"
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Both provide a part of the solution. Thanks
ASKER
The Grid Cell was too large and left aligning or creating another column did not look right. The float left looked much closer to what I needed
or
Text='<%# "$ " & Eval("MarketValue") %>'
what do you get?