Avatar of gogetsome
gogetsomeFlag for United States of America

asked on 

Keep paragraphs seperate when displaying data from database

Hello, I'm looking for ways to display in a datalist multiparagrah text that comes from an access database. Currently I'm populating a textbox and have it set to multiline and rows set to ten. The original formatting of the data is intact. If I use a label the paragraphs are run together. What is the best control to use in this situation? If it is textbox then how do you make the rows auto length?
Any help would be great!
ASP.NET

Avatar of undefined
Last Comment
NauticalNonsense
Avatar of NauticalNonsense
NauticalNonsense
Flag of United States of America image

Not sure if you can make the rows auto-length, but for the label, say you have the label in a datalist onitemdatabound, you could do

lbLongDescription.Text = dbr["LongDescription"].ToString().Replace(CHR(10), "<br />");

or something along those lines to convert the line breaks into BR's/ that will HTML format to a new line.
Avatar of gogetsome
gogetsome
Flag of United States of America image

ASKER

I would like to learn how to use the label to accomplish my needs, but I'm having trouble converting to vb and would I not have to use findcontol to work with the label in the datalist control with this code on the code behind?
lbLongDescription.Text = dbr("LongDescription").ToString().Replace(CHR(10), "<br />")

Can something like your code above be added to:
 <asp:Label ID = "label" runat="server" Text='<%# Eval("Description") %>'></asp:Label></td>

To make it work as well?
                                                     
Avatar of gogetsome
gogetsome
Flag of United States of America image

ASKER

For example... I'm looking all over the place and think this might work:
<asp:Label ID = "label" runat="server" Text='<%#Replace(Eval("Description"), vbcrlf, "<br/>") %>'></asp:Label>

It does keep the paragraphs seperate... Is there anything I'm missing with this approach? It does appear to work...
ASKER CERTIFIED SOLUTION
Avatar of NauticalNonsense
NauticalNonsense
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Thanks for the grade!
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo