title: Round MVC ViewBag variable to 2 decimal places
body: <p>I have 2 different fields saved in a database as money : Balance &amp; Amount. However when I try to display these on an mvc view, the Balance is already rounded to 2DP whilst the amount is being displayed as 4dp.</p>
  
  <pre><code> @foreach (var trans in ViewBag.Transactions)
  {
      &lt;tr&gt;
          &lt;td&gt;
              @trans.Date
          &lt;/td&gt;
          &lt;td&gt;
              @trans.Details
          &lt;/td&gt;
          &lt;td&gt;
              @trans.Currency
          &lt;/td&gt;
          @if (trans.AccountTo == ViewBag.SelectedAccount)
          {
              &lt;td&gt;
                 + @trans.Amount
              &lt;/td&gt;
              &lt;td&gt;
  
              &lt;/td&gt;
              &lt;td&gt;
                  @trans.AccountFrom
              &lt;/td&gt;
  </code></pre>
  
  <p>I have already tried @trans.Amount.ToString("#.##") or creating a helper similar to this: <a href="http://weblogs.asp.net/scottgu/archive/2011/05/12/asp-net-mvc-3-and-the-helper-syntax-within-razor.aspx" rel="nofollow">http://weblogs.asp.net/scottgu/archive/2011/05/12/asp-net-mvc-3-and-the-helper-syntax-within-razor.aspx</a>
  but still did not work. How can I round it to 2dp?</p>