mode...">All geek questions in one placeUse ToString () with @ Html.DisplayForWhy can't I use ToString ("#. ##") with @ Html.DisplayFor, for example:@Html.DisplayFor(modelItem => modelItem.Balance.ToString("#.##")) +4tostring asp.net-mvc razorrikket May 16, '13 at 23:04source share2 answerswhen I came across this before, I just added Getter to the model that View uses. public string FormattedBalance { get { return this.Balance.ToString("#.##"); } } And then just use it in your view: @Html.DisplayFor(ModelItem => ModelItem.FormattedBalance) +4Russ Clarke May 16 '13 at 23:14source shareDisplayFor displays the default ToString method for the specified model property.You can achieve what you want by writing your own @helper.See http://weblogs.asp.net/scottgu/archive/2011/05/12/asp-net-mvc-3-and-the-helper-syntax-within-razor.aspx0ptutt May 16, '13 at 23:13source shareSource: https://habr.com/ru/post/1481275/More articles:https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1481270/how-can-i-use-s3-object-names-as-inputs-to-an-mrjob-mapper-but-not-the-s3-objects-themselves&usg=ALkJrhg0mzAPKQqvqE-uADv7mhKKq70XcATBB memory leak when used inside an MFC application - c ++Ideas for measuring page load time - jsfFragmentPagerAdapter and FragmentStatePagerAdapter - performanceWhere can I find the JAVA library of visual effects and image manipulation? - javaFHIR resource that supports the concept without a known allergy - restHow to get TWindowsMediaPlayer to play a new track after completing the old? - delphiCannot use Dotfuscator with an application linking to Microsoft.Bcl.Async - .netC ++ / C Downloading a file from http using berkeleys / bsd sockets - c ++Do you need to reconnect an application purchase (IAP) to your application version after rejecting this application version? - iosAll Articles
Why can't I use ToString ("#. ##") with @ Html.DisplayFor, for example:
@Html.DisplayFor(modelItem => modelItem.Balance.ToString("#.##"))
when I came across this before, I just added Getter to the model that View uses.
public string FormattedBalance { get { return this.Balance.ToString("#.##"); } }
And then just use it in your view:
@Html.DisplayFor(ModelItem => ModelItem.FormattedBalance)
DisplayFor displays the default ToString method for the specified model property.
You can achieve what you want by writing your own @helper.
See http://weblogs.asp.net/scottgu/archive/2011/05/12/asp-net-mvc-3-and-the-helper-syntax-within-razor.aspx
Source: https://habr.com/ru/post/1481275/More articles:https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1481270/how-can-i-use-s3-object-names-as-inputs-to-an-mrjob-mapper-but-not-the-s3-objects-themselves&usg=ALkJrhg0mzAPKQqvqE-uADv7mhKKq70XcATBB memory leak when used inside an MFC application - c ++Ideas for measuring page load time - jsfFragmentPagerAdapter and FragmentStatePagerAdapter - performanceWhere can I find the JAVA library of visual effects and image manipulation? - javaFHIR resource that supports the concept without a known allergy - restHow to get TWindowsMediaPlayer to play a new track after completing the old? - delphiCannot use Dotfuscator with an application linking to Microsoft.Bcl.Async - .netC ++ / C Downloading a file from http using berkeleys / bsd sockets - c ++Do you need to reconnect an application purchase (IAP) to your application version after rejecting this application version? - iosAll Articles