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>
5
  • what do you mean, doesn't work? I see where MS says it does work with boundfield? can you switch? msdn.microsoft.com/en-us/library/… Commented Jul 7, 2014 at 14:51
  • Then i have to make boundcolumn to boundfield ? Does that make any confliction to the code behind >>?? Commented Jul 7, 2014 at 14:56
  • I could not answer this without seeing codebehind. I would guess that some changes would be in order. Commented Jul 7, 2014 at 14:59
  • i cant do anything with the boundcolumn ??? any extra code with htmlencoding i can write in code behind >?? Commented Jul 7, 2014 at 15:00
  • yes, that is correct.You can see David's solution, or mine, for reference. Commented Jul 7, 2014 at 18:27

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

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

2 Comments

how to use it with boundcolumn datagrid ??
please make answers? It helps others follow your solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.