Solved

new line character in gridview cell

Posted on 2009-03-31
2
1,777 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Different Delete Messages 7 37
Resolve Dependency Issues 4 48
C# HTTP GET method sample code 3 42
Variable Event ? 3 23
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…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now