how to render html tags on gridview from database

I have 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;


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.

You can try with this code

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

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")).Replcae("\n","<br />").Replcae("\r","<br />") %>

Hope this will help !!

Need Your Help

Depend on a branch or tag using a git URL in a package.json?

git dependencies npm branch git-tag

Say I've forked a node module with a bugfix and I want to use my fixed version, on a feature branch of course, until the bugfix is merged and released.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.