Esther B
Esther B

Reputation: 25

Replace ' with an Apostrophe '

I have a column called LastName in a GridView and it is pulling data correctly; however, people whose last names include an apostrophe ', like O'Connor, it shows up as O'Connor. How do I make it show an apostrophe and not a code? I am aware of a code System.Net.WebUtility.HtmlEncode(TEXT to ENCODE) which fixes such issue but I do not know how to apply it to the BoundField or if it will work in the BoundField? Please help.

<asp:BoundField DataField="LastName" HeaderText="Last Name" 
                SortExpression="LastName" />

Upvotes: 1

Views: 1119

Answers (1)

DLeh
DLeh

Reputation: 24395

Setting HtmlEncode="False" should work:

<asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName"
    HtmlEncode="False" />

More info: MSDN

Upvotes: 1

Related Questions