Textbox multiline property

zachvaldez used Ask the Experts™
I have a textbox that has multiline property set.
I output my data here from another page.

When it loads Id like the textbox to treat the new data as a new line not a continuation text or append.
Each new data entered should start with

on my page load event, I have this code..

If dr("CommentsHist") is system.dbnull.value = false then
   textBox1.text = dr("CaommentsHist")

Currently since textbox1 has mulitiline, each new data entered just appends it to previous data.

I prefer new line created everytime.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Try this:

If dr("CommentsHist") is system.dbnull.value = false then
   textBox1.text = dr("CaommentsHist") + Environment.NewLine

Open in new window

I think you made a typo on your original question, but I left it as you wrote it, just in case ;)
You could also append the Environment.Newline to the data coming from the other webpage.
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!


You could also append the Environment.Newline to the data coming from the other webpage--

show me how to please?

BTW the + Environment .newline adds as "," before the data such as example

Well you are passing the CommentsHist from another page into this page, correct?

If that's the case, then just add Environment.Newline to the end of the information you want to pass in the other webpage. ASP.NET will convert this Environment.Newline for you into the proper newline tag for the multiline TextBox.

Regarding the Environment.Newline adding in a "," before the data...I'm pretty sure that impossible. The Environment.Newline method will only create a newline break...it doesn't deal with text at all. You must have some data that put that "," in there. Double check if possible.
Most Valuable Expert 2012
Top Expert 2014

Looks like the data is coming from SQL. In SQL you can use following to add new line to end of string

Select Col1, Col2, Col3 + Char(10) + Char(13) As Col3 From ...
Well, it looked like the data was coming from a DataTable from another page and put into a session variable or querystring to pass to this page. So that's why I mentioned tacking on the Environment.Newline to the variable or querystring that was being passed in.


2 issues,
1.when I do the Add it adds the textbox but retains the information that loads on page_load event.
Is it possible that when it adds a new textbox , it is blank.

2. when I start to type with a number say 1992,1998 , there is is no ","
at the start of line however when I type text, it adds the "," in a new line though...


the comments helped in finding a solution.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial