title: C# HTML tags inside GridView
body: <p>I have a SharePoint web part that I wrote in C# which is used to display SQL Server data based on user selections. I pull the data with a DataReader, fill a DataSet with it, and set that DataSet as the DataSource in a GridView and add that control to my page:</p>
  
  <pre><code>GridView outputGrid = new GridView();
  outputGrid.CssClass = "OutputGrid";
  outputGrid.DataSource = flipped_ds1;
  outputGrid.RowDataBound += outputGrid_RowDataBound;
  outputGrid.DataBind();
  Controls.Add(outputGrid);
  </code></pre>
  
  <p>This gives me a simple HTML table with a declared CSS class and that's about it. The only problem I'm facing is that line breaks in the data fields are not being rendered at all. I'm simply getting a block of text that ignores the breaks that are present in the database when it's rendered to HTML. In stepping through my code, I see that the newlines are coming in as text in the form of "\r\n". I tried a regex:</p>
  
  <pre><code>Regex rgx = new Regex("\r\n");
  string inputStr = Convert.ToString(dr[x]);
  string outputStr = rgx.Replace(inputStr, "&lt;br /&gt;");
  newRow[ds3.Tables["Bobst Specs 3"].Columns[x]] = outputStr;
  </code></pre>
  
  <p>While that does detect and replace the newlines, I merely get the text "<br />" with no line breaks. In viewing the HTML source, it is inserting the following line where I specify "<br />":</p>
  
  <pre><code>&amp;lt;br /&amp;gt;
  </code></pre>
  
  <p>I also tried changing my SQL query to something along the lines of:</p>
  
  <pre><code>SELECT REPLACE (fldCustomerName, '. ', '.' + @NewLineChar)
  </code></pre>
  
  <p>This apparently renders more newlines. I can see that they are present, because if I also insert the regex they are affected, but do not create line breaks. I'm not sure how to replace these, and what with, to get the lines to actually break.</p>