Solved

HTMLEncode in Code-Behind GridView BoundField

Posted on 2008-10-02
2
3,610 Views
Last Modified: 2012-05-05
I have successfully created a GridView in my code and can add a BoundColumn too.  However, when the column is drawn on the page, the HTML tags are displayed.  

{.asp.vb code}
                        Dim dg As New GridView
                        dg.AutoGenerateColumns = False
                        dg.ShowHeader = False
                        dg.CssClass = "SubReqBox_on"
                        Dim dgc As BoundField = New BoundField()
                        dgc.DataField = "CRSubRequirement"
                        dgc.HtmlEncode = True
                        dgc.HtmlEncodeFormatString = True
                        dgc.InsertVisible = True
                        dg.Columns.Add(dgc)
                        dg.DataSource = ds
                        dg.DataBind()

The text in my DB that corresponds to CRSubRequirement would be something like:

<div>words words words</div>

And of course, I don't want those Div tags showing in my grid.
0
Comment
Question by:Steve Krile
2 Comments
 
LVL 16

Accepted Solution

by:
Gyanendra Singh earned 500 total points
ID: 22625174
use this for bound field

         <asp:boundfield datafield="Address"
            htmlencode="false"
            headertext="Address"/>
         

also set  htmlencode="false" for yr grid
0
 
LVL 16

Author Comment

by:Steve Krile
ID: 22625270
Aha!  If you don't want to see HTML, set HTMLEncode to false.  Sure..Got it!

The "answer" is then:

                       Dim dg As New GridView
                        dg.AutoGenerateColumns = False
                        dg.ShowHeader = False
                        dg.CssClass = "SubReqBox_on"
                        Dim dgc As BoundField = New BoundField()
                        dgc.DataField = "CRSubRequirement"
                        dgc.HtmlEncode = False  '<--IMPORTANT PART-->
                        dgc.HtmlEncodeFormatString = True
                        dgc.InsertVisible = True
                        dg.Columns.Add(dgc)
                        dg.DataSource = ds
                        dg.DataBind()


0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

786 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