-1

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.

Abhinav Konda
  • 225
  • 1
  • 11

2 Answers2

1

There is a option available in Boundfield of your grid view. HtmlEncode="false"

The code in my case

<asp:BoundField DataField="timeStamp" HeaderText="timeStamp" HtmlEncode="false" />
Ondipuli
  • 468
  • 3
  • 9
0

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>
Bharadwaj
  • 2,535
  • 1
  • 22
  • 35