Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

new line character in gridview cell

Posted on 2009-03-31
2
Medium Priority
?
1,950 Views
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),
	@InceptionDate AS SMALLDATETIME,
	@PostDate as DATETIME
AS
	Select [MortgageeID] AS 'Mortgagee Number', 
		[Name] AS 'Mortagee Name', 
		'Address' = CASE WHEN [Address2] = '' THEN
				[Address1] + ' \r ' + [City] + ', ' + [State] + '. ' + [ZipCode] 
			    ELSE
				[Address1] + ' \r ' + [Address2] + ' \r ' + [City] + ', ' + [State] + '. ' + [ZipCode]
			    END,
		[LoanID] AS 'Loan Number'
	From PlMortgage WITH (NOLOCK) 
	Where PolicyID = @PolicyID And 
		InceptionDate = @InceptionDate And 
		PostDate = @PostDate 
	Order by MortgageeID
GO

Open in new window

0
Comment
Question by:Unzip_The_Ripper
[X]
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
2 Comments
 
LVL 9

Accepted Solution

by:
vavjeeva earned 500 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/> '
0
 

Author Closing Comment

by:Unzip_The_Ripper
ID: 31564966
Perfect.  This fixed it.  Thanks.
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

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…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

688 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