Solved

new line character in gridview cell

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

11 Experts available now in Live!

Get 1:1 Help Now