Converting Characters to Other Characters from a DB

I have a SQL Server Database containing FAQ questions and answers...

I had no problem getting a page built to pull the info and write it to a page...
What I am having trouble figuring out is how to pull the info from the SQL DB and changing all of the newline ("\n") characters to HTML break tags ("<br />") so my output doesn't appear as one big paragraph...
I have databind (or is it databound? Or databinded?) to a repeater and cannot for the life of me figure out how to work with the DataBinder.Eval(Container.DataItem,"ANSWER") to convert the characters or even what function to convert the characters with...
I tried looking at Regex and HTMLWriter but again, no luck...
I have seen the light and am coming from a PHP background but in PHP, I would simply write a function to handle the conversion via a pregreplace() function... I tried this with Regex, but once I tried running the function on the DataBinder.Eval(Container.DataItem,"ANSWER"), it kept telling me that "Container" could not be found and that I need to make sure I am using a proper using call... or something to that effect.
I think it's because I do not fully understand how to convert the DataBinder.Eval to a string and then run the function... if the function is even written properly...
In closing, I don't even know if I am overcomplicating the whole process bt writing a wrapper function... that's why I haven't included the code... yet...
ah the joys of learning a new language...
so, if anyone can lend a ASP.NET convert newbie a hand in the proper direction, it'd be very appreciative...
thankyaverymuch...
Aarron
0
aszalacinski
8/26/2004 6:39:20 PM
asp.net.getting-started 91979 articles. 3 followers. Follow

3 Replies
614 Views

Similar Articles

[PageSpeed] 9

Here a really simple way off the top of my head:


// in your aspx file:
<%# ConvertToHTML(DataBinder.Eval(Container.DataItem,"ANSWER")) %>
// in your codebehind:
protected string ConvertToHTML(object myData)
{
return myData.ToString().Replace("\n", "<br />");
}

Basically you're passing in the container data as an object, converting it to a string, then calling the replace function which should replace all "\n" with "<br />".
Let me know if you need more help.
-- daver
0
daver
8/26/2004 8:05:12 PM
Man, that worked perfectly, thanks!!!!
0
aszalacinski
8/30/2004 2:07:12 PM
Shweeet!  You're welcome.
-- daver
0
daver
8/30/2004 5:55:37 PM
Reply:

Similar Artilces:

Error converting characters into server's character set. Some character(s) could not be converted.
Error converting characters into server's character set. Some character(s) could not be converted. No changes made to database. UPDATE Ticket_detail SET problem = 'mecho Team, I have set up several table repdefs in our test environment (PROD_jam) to determine the benefit of having table repdefs in addition to a database repdef. After I set up one of the table repdefs I ran several updates on the primary table to verify whether the where-clause was smaller on the replicate database. When I reviewed the transaction in the outbound queue on the secondary rep server (T...

How do I get the data character by character from a dw_1?
Hi I need to capture character by character the data at the time the user is entering the information on the dw_1 object input field. How do I get that? or it must be in a particular event? Thanks EN See EditChanged event of Datawidnow dw_1 .... but don't necessarily expect "character by character" data input. With a Ctrl-V, a user can paste thousands of characters into a field, and this will fire off only one EditChanged event. There is no event that will fire for each of these pasted characters. Be careful of your assumptions. Good luck, Terry [Team...

Getting error when saving to my db. Trying to limit number of character saved to db.
I am using the following INSERT command in my Source.  The 'notes' field in my DB is VarChar 7000 characters.  I am trying to limit the amout of characters that can be saved to 7000 characters to my db. InsertCommand="INSERT INTO [info] ([class_name], [info_date], LEFT([notes], 7000)) VALUES (@class_name, @info_date, @notes)"> If I try to submit more than 7000 characters I get the following error message. "An error occured while entering this record. Please verify you have entered data in the correct format." I thought that the Left 7000 would limit it to the fir...

Why am I getting "Too many characters in character literal" here?
Why am I getting "Too many characters in character literal" here? <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> I checked another project that compiles, and the line above is exactly the same...?Clay Shannon,author of historical works, novels, and art/poetryhttp://www.knowitallsports.com/booklinks.aspx Are you sure that's the line causing the error?That error usually happens when you use single quotes when you should have used double quotes. Please Mark As Answer posts that ...

getting double the characters when receiving non-English characters [Edit]
Hi, I have a webbroker standalone application receiving requests from a sms cloud service (Twilio). It's sending the SMS or texting body from a mobile phone. Everything works fine if I receive English characters. If other characters are sent (like French or Greek), I get double the characters and they are weird characters - not the right ones. I suspect that it's being sent as utf8 encoded. And when there's non-English, it's 2 bytes ... for some reason this turns into 4 bytes by the time it gets to: text := Request.Content.Fields['Body']; ??? I don...

Convert Existing User DB to Net .net MemberShip DB
Hey, Im looking to take my current Users DB and put those records into the new .net membership DB. I looked at the Membership Create User SP but im not sure if that sp is the only procedure that gets called when creating a user. I was wondering if any one else has had to do this and how should i go about it. I have about 100 users that i need to copy over. Thanks. This article has a bunch of links to Membership and security information in ASP.NET: http://weblogs.asp.net/scottgu/archive/2006/02/24/438953.aspx For migrating 100 users over, you might just find it easiest to create a ...

Error converting characters into server's character set.
Hello, I am running Sybase ASE as repository (Forms) for application development. I try load some forms (10 MB) into application (its repository in Sybase) but I ve got this message: Error converting characters into server's character set. Some character(s) could not be converted. (Sybase SQL Server error number : 2402 severity : 16 state : 11) I know theese commands : sp_configure "enable unicode conversions" and set char_convert But I dont know which one I need to use it or how exactly I have to use it for conversion of imported data... David ...

I am only getting the first character back !! from the DB
 I am using the Enterprise Library  and i have the following method:   When the output field is a int I have no problems getting back the whole number, but if the field that is comming back from the sql is a varchar  then I keep getting only the first character   public string GetUserName(long UserId) { try { string userName; DiscussionDB data = new DiscussionDB(); List paramlist = new List(); paramlist.Add(data.CreateParameter("@UserId", UserId)...

Problem:getting double the characters when receiving non-English characters [Edit]
Hi, I have a webbroker standalone application receiving requests from a sms cloud service (Twilio). It's sending the SMS or texting body from a mobile phone. Everything works fine if I receive English characters. If other characters are sent (like French or Greek), I get double the characters and they are weird characters - not the right ones. I suspect that it's being sent as utf8 encoded. And when there's non-English, it's 2 bytes ... for some reason this turns into 4 bytes by the time it gets to: text := Request.ContentFields.Values['Body']; ??? I ...

getting double the characters when receiving non-English characters [Edit] #2
Hi, I have a webbroker standalone application receiving requests from a sms cloud service (Twilio). It's sending the SMS or texting body from a mobile phone. Everything works fine if I receive English characters. If other characters are sent (like French or Greek), I get double the characters and they are weird characters - not the right ones. I suspect that it's being sent as utf8 encoded. And when there's non-English, it's 2 bytes ... for some reason this turns into 4 bytes by the time it gets to: text := Request.ContentFields.Values['Body']; ??? I ...

getting double the characters when receiving non-English characters [Edit] #2
Hi, I have a webbroker standalone application receiving requests from a sms cloud service (Twilio). It's sending the SMS or texting body from a mobile phone. Everything works fine if I receive English characters. If other characters are sent (like French or Greek), I get double the characters and they are weird characters - not the right ones. I suspect that it's being sent as utf8 encoded. And when there's non-English, it's 2 bytes ... for some reason this turns into 4 bytes by the time it gets to: text := Request.ContentFields.Values['Body']; ??? I ...

WARNING! Some character(s) could not be converted into client's character set.
I received this message when it was executing the command SELECT. Which is the reason? Paulo wrote: > I received this message when it was executing the command > SELECT. Which is the reason? Ignore it ... that simlpy means some characters that are in the result set cannot be displayed on your terminal ( e.g. Unicode characters that are beyond your terminal's capability ). ...

BCP Error: Some character(s) could not be converted into client's character set.
I get the following error on BCP out of a table. Server Message: alpbsfra12 - Msg 2403, Level 10, State 0: WARNING! Some character(s) could not be converted into client's character set. Unconverted bytes were changed to question marks ('?'). The table contains 1835315 rows and the BCP has been split into a number of 'chunks'. So that the files produced contain 250000 rows a time. On the final bcp we use start and end rows of 1750000 - 2000000 (i.e. -F 1750000 -L 2000000) NB the commands are auto generated. This is the only bcp that produces this error...

'Some character(s) could not be converted into client's character set....'
All-- Received this error from a PB 7.0.3 app running against Sybase 12. One of the suggested workarounds is to run sp_configure against Sybase to enable Unicode. (We are not at all in favor of doing that.) The other alternative is to translate our ANSI-codepage app into Powerbuilder for Unicode. What *is* PowerBuilder for Unicode, and how do we get our hands on it? Is it an add-on, or is it bundled with the ANSI version? TIA, Matt Seltzer IT Tech Analyst, EMI Recorded Music, NA Matt.Seltzer@emicap.com ...

Web resources about - Converting Characters to Other Characters from a DB - asp.net.getting-started

PastBook’s Filepicker.io Integration Eases Process Of Converting Facebook Content To Books
PastBook , one of several companies that allow Facebook users to publish their content on the social network in actual books , announced the ...

Facebook No Longer Converting Groups Into Pages
Back when Facebook first launched Facebook Pages, many businesses and brands who had built up substantial audiences in their Facebook Groups ...

Zwartz Laminating-Converting B.V. on the App Store on iTunes
Get Zwartz Laminating-Converting B.V. on the App Store. See screenshots and ratings, and read customer reviews.


"Occupier" Thanked Former Soviet Citizen for "Converting" Him to Capitalism, Pro-Israel, Pro-USA - YouTube ...
May Day Demonstration on Union Square in New York City Zionism & Birth of Modern Israel in 1948: Former Soviet Citizen Pays Tribute to Ben-Gurion ...

Click go fears of converting print files
Is there a way to convert a print queue item to a .RTF or .PDF file? I like to save or email them. - The Sydney Morning Herald

Sudanese woman ordered to hang under sharia law for converting to Christianity gives birth
Khartoum, Sudan: A Christian Sudanese woman sentenced to hang for apostasy has given birth in jail, a Western diplomat said on Tuesday.

Imams warn against radicalism to Aboriginal inmates converting to Islam
The prison system has enlisted the help of ASIO to crack down on radicalisation behind bars amid revelations that Aboriginals are converting ...

Converting the world's companies one by one - The Science Show - ABC Radio National (Australian Broadcasting ...
Image: Trucks carrying logs make their way up a road in Jambi, Indonesia. A vast area of the Sumatran forest, and orangutan habitat, is being ...

Converting Churches Into Homes Is The Latest Hollywood Trend
You don't have to be a believer to be moved by the beauty of a church.

Resources last updated: 12/15/2015 9:43:09 PM