DISABLING HTMLENCODE IN ASP.NET AND C#

Chintoo Semi

Total Post:135

Points:947
Posted by  Chintoo Semi
C#  Gridview 
 1295  View(s)
Ratings:
Rate this:

I am using DataTable to populate data in GridView in ASP.NET I am trying to place a line break in a cell inside the DataGrid View I used

   "data1+<br>+data2"

to place a line break.I am manipulating this data from C# which is being generated dynamically.Because of HTML encoding 
is replaced as

 lt;brgt;

So please tell me how to disable that html encoding if possible for that gridView.

  1. john rob

    Post:108

    Points:756
    Re: Disabling HTMLencode in ASP.NET and C#

    TemplateField allows you to add html inside a cell, as

    <asp:GridView ID="gv" runat="server" AutogenerateColumns= "false">
     <columns>
        <asp:BoundField DataField="col_name" HeaderText="Header"/>
        <asp:TemplateField>
          <ItemTemplate>
             '<%#Eval("data1")%>'
              <br/>
             '<%#Eval("data2")%>'
          </ItemTemplate>
        </asp:TemplateField>
     <columns>
    </asp:GridView>

      Modified On Apr-06-2018 05:57:30 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!