I am reading in a field from the database and displaying in a GridView and in that field it contains <br/> tags in the text. So I am trying to remove these from the code but when I check the value of e.Row.Cells[index].Text it doesn't contain <br/> and is has ;br/> instead.
So I tried creating a function that removes any substring starting with < and ending with > or starting with & and ending with ;. The code removes the <> but it is still showing br/
Code:
index = gv.Columns.HeaderIndex("Message");
if (index > 0)
{
string message = RemoveHTMLMarkup(e.Row.Cells[index].Text);
e.Row.Cells[index].Text = message;
}
static string RemoveHTMLMarkup(string text)
{
return Regex.Replace(Regex.Replace(text, "<.+?>", string.Empty), "&.+?;", string.Empty);
}
How do I remove the <br/> tag?
