title: How do you make an MVC Webgrid show multiple lines in a cell?
body: <p>I have a function in code that generates a string <code>A\nB\nC</code>, when it is pulled into my Webgrid, I use a function on the Razor side to change the <code>\n</code> to a <code>&lt;br /&gt;</code>, and I know this works because in the webpage source it shows the string on three separate lines.</p>
  
  <p><code>@functions {
      public static string ReplaceLineBreaks(string s) {
          return s.Replace(Environment.NewLine, "@Html.Raw(&lt;br /&gt;)");
      }
  }</code></p>
  
  <p><code>&lt;div id="grid_MyWebGrid"&gt;
      @grid.GetHtml(
          tableStyle : "table",
          alternatingRowStyle : "alternate",
          headerStyle : "header",
          columns: grid.Columns(
              grid.Column("Letters", format: item =&gt; 
                  @Html.Raw(ReplaceLineBreaks(Html.Encode(item.Letters)))),
          )
      )
  &lt;/div&gt;</code></p>
  
  <p>But when I load the page, the cell for that column shows:</p>
  
  <p><code>ABC</code></p>
  
  <p>Instead of:</p>
  
  <p><code>A
  B
  C</code></p>
  
  <p>Is there something in WebGrid that lets you tell it that that column is to be used as a multi-line cell?</p>