• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 380
  • Last Modified:

Why does GridView not decode HTML?

In asp.net 3.5, I'm adding values to a Dictionary<string, string>, which I then assign to a GridView.  I do a

string mystring = "<a href="www.abc.com">go here</a>";
myDictionary.Add("KeyOne", Server.HtmlDecode(mystring));

but in the aspx, it comes out in the grid as the full string rather than a clickable link.  When I view source, I can see it has turned the carrots into escaped characters.  What am I doing wrong?  I've also tried UrlDecode().
1 Solution
Refael AckermannCommented:
It depends on the fields of the GridView. By default (with AutoGenerateColumns=true) you get a bound field that is set to encode HTML.

You can use the following:
<asp:gridview ...>
     <asp:boundfield datafield="Country" htmlencode="false" headertext="Country"/>


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now