Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MVC3
HI Friends,
 
I have been using the MVC i have created the partial view and rendering the content form the model.
 
but when i making it string.format it is not formatted.
 
sample code i am placing for the referance.
 
<tr bgcolor="#ffeadf">
       <td align="left">
           <%=result.ShowYear%>
       </td>
       <td align="left">
           <%=string.Format("{0:c}",result.ShowProjectRevenu)%>
       </td>
   </tr>
 
the plain contantes are displaying
I have tried goggling also but not understand why that format is not applying on the string.
 
Please help me.
 
Thanks
Posted 16-Aug-12 23:40pm
Edited 19-Aug-12 19:20pm
AditSheth4.5K
v2
Comments
adit_sheth at 17-Aug-12 4:47am
   
is your spell for format is correct? and also F is in Upper letter.
"string.Format"
deepakaitr12345 at 18-Aug-12 7:41am
   
Thanks for the reply.I have placed the string.Format correctly
 
the problem was solved by using the following statements
 
1)Add the name space System.globlization
 
2) <%="$ "+result.ShowProjectRevenu.ToString("0,0", CultureInfo.InvariantCulture)+".00"%>
 
Thanks

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

you have string.formate. It's string.Format. <%= is ASP.NET syntax, I don't know if that even works in MVC3, you should use Razor syntax, it's more readable and people like me will be better able to help you if you're using what everyone else is.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 295
1 OriginalGriff 249
2 Sergey Alexandrovich Kryukov 205
3 Aajmot Sk 197
4 Sinisa Hajnal 176
0 OriginalGriff 7,800
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,790


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 20 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100