Solved

new line character in gridview cell

Posted on 2009-03-31
2
1,835 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
2 Comments
 
LVL 9

Accepted Solution

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

Author Closing Comment

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

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

807 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