Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert line break in a cell of a grid view?

Tags:

html

asp.net

I want to know how to put a line break in a cell of a grid view. Right now, I put

1
1
1

However, this renders as

1 1 1

How do I fix the line breaks so that each digit is displayed on its own row?

like image 438
ritika Avatar asked Nov 08 '10 11:11

ritika


2 Answers

Add HtmlEncode="False" to asp:BoundField and in the text, should have < br/> for line breaks as:

<asp:BoundField DataField="Address" HeaderText="Address" HtmlEncode="False" />
like image 63
Dil Avatar answered Oct 18 '22 20:10

Dil


You'll need to use the <br/> tag to put a line break in your html.

You can use String.Replace(new char[] { '\n' }, "<br>") to get the values with line-breaks replaced with <br/> in C#.

like image 45
Vivian River Avatar answered Oct 18 '22 19:10

Vivian River