This is a migrated thread and some comments may be shown as answers.

Prevent HTML Markup in Grid Column

7 Answers 386 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Temp
Top achievements
Rank 1
Temp asked on 08 Jul 2008, 12:15 AM
Is there an easy way for me to prevent html markup showing in grid columns?
I would like to server.htmlencode the contents of the field I guess.

7 Answers, 1 is accepted

Sort by
0
Missing User
answered on 09 Jul 2008, 02:35 PM
Hi Temp,


You can put it in the ItemDataBound event handler. The ItemDataBound event is raised when a data item is bound to data in the RadGrid control. This allows you to provide an event-handling method that performs a custom routine, such as modifying the values of the data bound to the item, whenever this event occurs. 

I have prepared especially for you a sample application which represents how to modify the text in appropriate columns
Please review the code in the project for further details, and let me know if you need further assistance.

Greetings,
Plamen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Temp
Top achievements
Rank 1
answered on 11 Jul 2008, 12:05 AM
Thanks for your help.
0
Jason Lee
Top achievements
Rank 1
answered on 11 Sep 2008, 11:25 AM
Dear Sir,

Is there a better way to make it?
I want to encode html markup in grid column, too.  However, I have already used RadGrid in lots of pages.  Moreover,  it seems to write codes in ItemDataBound event handler for each column......

Suggestion:
Is possible radGrid to provide a property, such as "EncodeHTMLMarkupInColumn"...
If the property is true, all the content will be encoded?

Thank you

0
Jason Lee
Top achievements
Rank 1
answered on 12 Sep 2008, 04:39 AM
Dear Sir,

It seems GridView server control support what I said

<asp:GridView ID="grvResult" runat="server" AutoGenerateColumns="False" Width="100%">

    <Columns>

        <asp:BoundField HeaderText="OperationDate" DataField="OperationDate"  HtmlEncode="True">

        </asp:BoundField>     

        <asp:BoundField HeaderText="TotalRate" DataField="TotalRate"  HtmlEncode="True">

        </asp:BoundField>

    </Columns>

</asp:GridView>


0
Nikolay Rusev
Telerik team
answered on 12 Sep 2008, 03:09 PM
Hello Jason,

HtmlEncode property to GridBoundColumn will be added for the Q3 2008 release, expected at the beginning of November. I hope this is good news for you.

Kind regards,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Phillip
Top achievements
Rank 1
answered on 14 Feb 2009, 03:38 AM
HI Jason,

I am having the same problem for the RadComboBox, where all the HTML is displaying encoded. For example '&' is displaying as '&amp;'.

Any ideas?

Thanks
Phil

0
Veselin Vasilev
Telerik team
answered on 16 Feb 2009, 03:34 PM
Hello Phillip,

You can use HtmlDecode method in such cases.

Greetings,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Temp
Top achievements
Rank 1
Answers by
Missing User
Temp
Top achievements
Rank 1
Jason Lee
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Phillip
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or