If you are displaying text in a GridView control that contains line feeds, it won’t display correctly. You would think that setting the HtmlEncode property in a BoundField would do the trick, but no! Nothing I did would work. Below is the only work around that I could find:
protected void EventLogMessagesGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[0].Text = e.Row.Cells[0].Text.Replace(System.Environment.NewLine, “<br/>”);
}
If you have a better way, please let me know.
Tip Submitted By: David McCarter
Discover more from dotNetTips.com
Subscribe to get the latest posts sent to your email.
