new line character in gridview cell

Posted on 2009-03-31
Last Modified: 2012-05-06
How do I get newline characters to work in a gridview cell?

I have the query below for now.  It doesn't work, nor do any other newline characters when I reference the column in my gridview.  I want the address to be formatted like:

555 Test Dr.
Exam, FL. 55555

Instead I get:

555 Test Dr. \r Exam, FL. 55555
CREATE PROCEDURE dbo.usp_SEL_CL_Net_GetMortgageInformation
	@PolicyID AS VARCHAR(15),
	@PostDate as DATETIME
	Select [MortgageeID] AS 'Mortgagee Number', 
		[Name] AS 'Mortagee Name', 
		'Address' = CASE WHEN [Address2] = '' THEN
				[Address1] + ' \r ' + [City] + ', ' + [State] + '. ' + [ZipCode] 
				[Address1] + ' \r ' + [Address2] + ' \r ' + [City] + ', ' + [State] + '. ' + [ZipCode]
		[LoanID] AS 'Loan Number'
	From PlMortgage WITH (NOLOCK) 
	Where PolicyID = @PolicyID And 
		InceptionDate = @InceptionDate And 
		PostDate = @PostDate 
	Order by MortgageeID

Open in new window

Question by:Unzip_The_Ripper
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

vavjeeva earned 125 total points
ID: 24032158
set the htmlencode to false in gridview field and change the query from \r to <br\>

<asp:BoundField HtmlEncode=false ........../></Columns>


instead of
[Address1] + ' \r '

[Address1] + ' <br/> '

Author Closing Comment

ID: 31564966
Perfect.  This fixed it.  Thanks.

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question