title: Represent string as currency or decimal using razor @Html.textboxfor
body: <p>I have an ASP.NET MVC App. I am building an HTML table using razor syntax. The page model is defined as</p>
  
  <pre><code>@model IEnumerable &lt; DealView.Models.deal &gt;
  </code></pre>
  
  <p>and the model has a property</p>
  
  <pre><code>public string price { get; set; }
  </code></pre>
  
  <p>which can be a number or null.</p>
  
  <p>I am trying to get the textbox for to show comma's (ie 1,000,000) or even better currency ($1,000,000). At the moment I am just getting (1000000) using</p>
  
  <pre><code>@foreach (var item in Model)
      {
          &lt;tr&gt;
              ...
              &lt;td&gt;@Html.TextBoxFor(modelItem =&gt; item.price, new { id = string.Format("
                     {0}_price", item.ID) })&lt;/td&gt;
              ...
          &lt;/tr&gt;
      }
  </code></pre>
  
  <p>I have tried <code>item.price.asint()</code> but think the null instances causes problems. Any advice is appreciated. I am not married to the <code>TextBoxFor</code> if there is a better helper function to use.</p>