Click here to Skip to main content
15,351,370 members
Articles / Web Development / ASP.NET
Posted 12 Nov 2007


31 bookmarked

Multi Line GridView Column Cell

Rate me:
Please Sign up or sign in to vote.
2.90/5 (16 votes)
12 Nov 2007CPOL
Display multi line of text saved in the database


I was working on a project , where I had to retrieve what was saved in the database and display it in the same cell, but multi line. Since the data was saved in the format of <br>, it was easy for me to display it.

  1. Create a new project using C#.

  2. Create a table in the database (SQL or MYSQL table or any other database):

    Screenshot - T7.jpg

  3. Save some data to the table. For example:

    Screenshot - T6.jpg

  4. Before you save the data to the table, replace the \r\n with <br>:

    Screenshot - T5.jpg

  5. Drag and drop GridView from the Tool Kit to the Web form.

  6. Create the following columns:

    Screenshot - T1.jpg

  7. Gridview will appear like this:

    Screenshot - T2.jpg

  8. Change the property of the Message column as shown below:

    Screenshot - T3.jpg

  9. Set the HtmlEncode to false.

  10. Write the code to fill the GridView. Here is a sample:

    Screenshot - T4.jpg

  11. The data will appear like this:

    Screenshot - T8.jpg

Points of Interest

It can be used to display text file data saved in the database.

It was very nice and easy to display multi lines of text in one cell. What we need to do is set the HtmlEncode property to false.


  • 12th November, 2007: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Chief Technology Officer
United States United States
More than 15 years of experience in design, architecture and development of various commercial objects oriented application.Other Specialties

Data Migration:
• MS Access database to SQL 2005/2008
• MS Access database to Oracle
• MS Access database to My SQL
• FoxPro to SQL

Application Migration:
• Converted MS Access application to .net web application (
• Excel Application to .net 3.5 web application
• FoxPro application to .net 3.5
Reporting development and support
• MS access reports
• Crystal reports
• SQL Reports(SSRS)
• DevExpress reports
• Cognos reports
Application development and support
• .net Application web /Win forms
• SharePoint
• MS Access
• Website
• Ecommerce
• Web Services
3rd Party Control Support
• DevExpress
• .netForum
• Telerik
Version controls Support
• Team Foundation Server
• Source Safe

Comments and Discussions

GeneralMy vote of 2 Pin
Donsw26-Nov-08 16:55
MemberDonsw26-Nov-08 16:55 
GeneralBetter title - Render HTML in GridView Cell Pin
Jcmorin12-Nov-07 10:54
MemberJcmorin12-Nov-07 10:54 
I think this article is more about rendering HTML inside the grid than the multi-line issue.
Don't forget that some people like me, think about rendering multi-line of the table together.

Something like this html example, but for the grid.
<br />
<table><br />
	<tr><br />
		<td rowspan="2">Multi-line text</td><br />
		<td>Line 1</td><br />
	</tr><br />
	<tr><br />
		<td>Line 2</td><br />
	</tr><br />
</table><br />

GeneralRe: Better title - Render HTML in GridView Cell Pin
T.Ashraf12-Nov-07 19:08
MemberT.Ashraf12-Nov-07 19:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.