0

I have some data in database which I am binding it to a bound column. Data contains many html tags. But I want to display it as TEXT only "NOT TO RENDER IT"

I am not sure because HTMLENCODE property doesn't work with boundcolumn. Please help.

Also just to add I have multiple datagrids binding with bind() function and are using one event handler Itemdatabound.

<asp:boundcolumn datafield="content" readonly="True" headertext="Product ID ">
<headerstyle horizontalalign="Center" width="100px"></headerstyle>
<itemstyle horizontalalign="Left" width="100px"></itemstyle>
</asp:boundcolumn>
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Simon
  • 1
  • 5
  • what do you mean, doesn't work? I see where MS says it does work with boundfield? can you switch? http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.htmlencode(v=vs.110).aspx –  Jul 07 '14 at 14:51
  • Then i have to make boundcolumn to boundfield ? Does that make any confliction to the code behind >>?? – Simon Jul 07 '14 at 14:56
  • I could not answer this without seeing codebehind. I would guess that some changes would be in order. –  Jul 07 '14 at 14:59
  • i cant do anything with the boundcolumn ??? any extra code with htmlencoding i can write in code behind >?? – Simon Jul 07 '14 at 15:00
  • yes, that is correct.You can see David's solution, or mine, for reference. –  Jul 07 '14 at 18:27

2 Answers2

0

Server.HtmlDecode()

This will allow you to print the tags without rendering them to html.

http://msdn.microsoft.com/en-us/library/hwzhtkke(v=vs.110).aspx

David Pullar
  • 706
  • 6
  • 18
0

Prevent HTML encoding in auto-generated GridView columns

extract from possible solution from above link:

<asp:TemplateField HeaderText="myLink" SortExpression="myLink">
    <ItemTemplate>
        <asp:Literal ID="litHyperLink" runat="server" Text='<%# Bind("myLink", "{0}") %>' />
    </ItemTemplate>
</asp:TemplateField>

Or bind your own columns, also shown in above link

Community
  • 1
  • 1