[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Problem with label and text out of MSSQL

Posted on 2006-05-10
12
Medium Priority
?
282 Views
Last Modified: 2012-05-05
Hi,

My app exists of 2 steps.

In step 1 people could give comments in textboxes (multiline) and this is stored in a MSSQL database.

Step 2 is to create a page that shows all this information. When I create a textbox and get the information out of the database, it works perfect.

But the idea is to put this information in a label. When I retreive the information from the database and put this in a label, all the return characters seem to be missing. So the layout of these boxes is nothing. Is there a way to get these return characters so that everything is shown good?

Thanks in advance!!!

Jerry
0
Comment
Question by:Jerry_0001
12 Comments
 

Author Comment

by:Jerry_0001
ID: 16647967
I'll rephrase it.

How can I change the return character that is stored in the database to a vbCrlf?

Thanks
0
 
LVL 15

Expert Comment

by:GavinMannion
ID: 16648093
if the person hits <enter> in the multiline textbox a char of \r\n should be stored.

So all you will need to do is string.Replace("\r\n","vbCrlf")
0
 

Author Comment

by:Jerry_0001
ID: 16648194
Thanks for the help already.

I don't know why, but it's not working like this.

Dim tmp As String = dr(6)
tmp = tmp.Replace("\r\n", "vbCrlf")
lblVis.Text = tmp

But the text in the labels also isn't showing the \r\n characters. Shouldn't I have to see them then? In the database there aren't any of those characters either, but there the text starts on a new line (in the same cell).

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Assisted Solution

by:Torrwin
Torrwin earned 200 total points
ID: 16648353
When you store the textbox data in the database make a loop that iterates through each line of the textbox.  At the end of each line add an html break <br>.  Then, when this data is placed in the label it should appear correctly.
0
 

Author Comment

by:Jerry_0001
ID: 16648408
I think I may have a small problem then. People are already using the part where they can fill in the textboxes.

I'm now making the results of what they all filled in.

Isn't there any other solution?
0
 
LVL 15

Expert Comment

by:GavinMannion
ID: 16648649
You should be able to take a look at dr(6) while debugging and see what character is being loaded.

If you put the text back into a textbox do the carriage returns show?
0
 

Author Comment

by:Jerry_0001
ID: 16648730
When you put it back in a textbox, then it works.

I've also tried BitConverter.ToString(System.Text.Encoding.Unicode.GetBytes(tmp)). This shows 00-0D-00-0A when there should come a new line.

0
 
LVL 15

Assisted Solution

by:GavinMannion
GavinMannion earned 200 total points
ID: 16648747
There must be something showing the character in the debug window. but you can always use the option you came up with and just replace 00-0D-00-0A with<br>

I do agree with Torrwin though, it should be changed during the save.
0
 

Author Comment

by:Jerry_0001
ID: 16648796
How can you add the <BR> at the end of each line of the textbox?

I'll first do that, and then I will change the rest manual in the db.
0
 
LVL 22

Accepted Solution

by:
Jason Scolaro earned 400 total points
ID: 16648859
Jerry_0001,

Here is your solution:  Label1.Text = Convert.ToString(dr(6)).Replace(vbCrLf, "<br />")

I actually choose to save the contents of the TextBox as is in the database.  This way I have the option of placing the data back into a TextBox (for editing) OR throwing it in a Label (for displaying).  The only thing is when you use a Label, HTML ignores your Carriage Return/Line Feeds (vbCrLf), so you must replace those with an HTML element (<br />).  

That's really all there is to it.  Good luck!
-- Jason
0
 

Author Comment

by:Jerry_0001
ID: 16648933
Yes, that it!!!!

Thanks for the help. Since you all helped me, I'll give you all some points :o)


Thanks again!!!!
0
 
LVL 15

Expert Comment

by:GavinMannion
ID: 16655905
Scolja's the man :)....

You can see I spend more time in C# than VB :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Loops Section Overview
Suggested Courses

872 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