2
votes

I have asp.net grid view to display techs notes. I am trying to force the grid view to display it as user enterd in text area

note: the grid view display the note in one line without break line or orderlist

example user Enter look like this

-hello World 1

-hello World 2

-hello World 3

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque gravida nibh mauris. Nam sit amet orci quis justo lacinia dictum nec vitae elit. Integer id nulla vitae nunc aliquam fringilla. Donec et nibh et odio ultrices cursus et quis lectus. Vestibulum ac tellus sit amet elit ullamcorper adipiscing. Quisque eu nisi eros. Integer dignissim, mi id tempus cursus, nisl dui euismod massa, adipiscing tincidunt dolor turpis ac magna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;

3

3 Answers

0
votes

I don't know of any ready made way to do this. So just convert newlines to <br> tags and make other needed changes manually.

Or you can do something a little more fancy by converting newlines into new HTML paragraphs like I did in my article Converting Text to HTML.

0
votes

You can try with this code

var input = "-hello World 1 -hello World 2";
var result = input.Replace("-",Environment.NewLine + "-" );
0
votes

Its because when you entered the data in text area. It generates \n or \r for new line. And in terms of html it doesn't break the line. So the solution is replace these characters with
tag.

for example in the bind expression use this :

<%# Convert.ToString(Eval("Content")).Replace("\n","<br />").Replace("\r","<br />") %>

Hope this will help!