How To Stop Gridview Column From Automatically Encoding Html Entities
I am fairly new to asp.net and come into a problem whilst using a gridview. I have added some entries that contain the '&' symbol eg 'PR Murphy & Associates'. I haven't don
Solution 1:
In the GridView's menu, you can select the column and under the properties for that column you can set HTMLEncode to False (or True depending upon your needs).
Solution 2:
I solved this problem with GridView1_RowDataBound
Event
protectedvoidGridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
string encoded = e.Row.Cells[i].Text;
e.Row.Cells[i].Text = Context.Server.HtmlDecode(encoded);
}
}
}
Post a Comment for "How To Stop Gridview Column From Automatically Encoding Html Entities"