[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Why does GridView not decode HTML?

Posted on 2008-11-13
1
Medium Priority
?
376 Views
Last Modified: 2013-11-08
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().
0
Comment
Question by:brettr
1 Comment
 
LVL 7

Accepted Solution

by:
moseack earned 2000 total points
ID: 22954260
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 ...>
  <columns>
     <asp:boundfield datafield="Country" htmlencode="false" headertext="Country"/>
...

See:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.htmlencode.aspx


0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month18 days, 2 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question