469,328 Members | 1,327 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,328 developers. It's quick & easy.

Display Multiple Rows in TextBox

Hi all,

How do I display multiple database rows in the one textBox?

The textBox is bound to the Database table and should display 3 database values.

However it displays only one.

How do I join table rows??

e.g. My table has 3 rows with same ID and want them all displayed in textBox...

myField ID
----------------- ---------------
itemA 2
itemB 2
itemC 2

thanks.
May 30 '07 #1
10 15861
Hi all,

How do I display multiple database rows in the one textBox?

The textBox is bound to the Database table and should display 3 database values.

However it displays only one.

How do I join table rows??

e.g. My table has 3 rows with same ID and want them all displayed in textBox...

myField ID
----------------- ---------------
itemA 2
itemB 2
itemC 2

thanks.
Set the "Multiline" property of the TextBox to true. Then you can display whatever you want.
Or you could use a RichTextBox instead.
May 30 '07 #2
Tried "Multiline" but no difference.

The textBox is bound to a dataset but only one row is displayed in it.
May 30 '07 #3
Tried "Multiline" but no difference.

The textBox is bound to a dataset but only one row is displayed in it.
Hmmm, never used a TextBox in that way. Have you tried to see how the RichTextBox behaves?
May 30 '07 #4
Hmmm, never used a TextBox in that way. Have you tried to see how the RichTextBox behaves?

hi ,
please try to set the textmode is "multiline" for corresponding textbox its working.

Thanks,
http://www.tryangled.com
http://www.tryangled.net
http://iteamweb.com
May 30 '07 #5
Plater
7,872 Expert 4TB
I am not sure you can use a texbox in that mannor, it's possible, but seems counter-intuitive. You have uniquely seperated lines that you just want to jumble into a big textbox
If you just wish to display the data, a ListBox might be a better fit.
Or you could make a middleman function in between what your database returns and what your textbox gets bound to. That function would read in all the data from the database and mush it into the textbox.
May 30 '07 #6
Frinavale
9,735 Expert Mod 8TB
Tried "Multiline" but no difference.

The textBox is bound to a dataset but only one row is displayed in it.
Is the problem that the data from the database is being displayed:
"itemA 2 itemB 2 itemC 2"

Or is it that you're only displaying:
"itemA 2"

You may have to put "new lines" in after each row retrieved from the database?
How are you filling the textbox?
May 30 '07 #7
Is the problem that the data from the database is being displayed:
"itemA 2 itemB 2 itemC 2"

Or is it that you're only displaying:
"itemA 2"

You may have to put "new lines" in after each row retrieved from the database?
How are you filling the textbox?
it's only displaying "itemA"

I want it to display itemA,itemB,itemC
Do I have to use a loop for this??

TextBox is bound to a dataset.
Using Visual Studio 2005. DataBindings Text Property set as... fundsAffectedEditBindingSource - myFunds
May 31 '07 #8
Vidhura
99
Suggestion:
Instead you could do the concatenation in db itself as follows



declare @abbr varchar(1000)

select @abbr=COALESCE(@abbr+ ',', '')+Col1 from Table where ID=@ID
select @abbr




it's only displaying "itemA"

I want it to display itemA,itemB,itemC
Do I have to use a loop for this??

TextBox is bound to a dataset.
Using Visual Studio 2005. DataBindings Text Property set as... fundsAffectedEditBindingSource - myFunds
May 31 '07 #9
Frinavale
9,735 Expert Mod 8TB
it's only displaying "itemA"

I want it to display itemA,itemB,itemC
Do I have to use a loop for this??

TextBox is bound to a dataset.
Using Visual Studio 2005. DataBindings Text Property set as... fundsAffectedEditBindingSource - myFunds
Check out this .NET article on how to use a database in your program. Try using the examples in your program...especially look at the section on "Executing Your SQL Commands". The only change you'll have to make is to add a loop that looks like:
Expand|Select|Wrap|Line Numbers
  1. While myDataReader.Read
  2.           TextBox1.Text = TextBox1.Text + " " + CType( dr.Item("FieldName"), String)
  3. End While
  4.  
Hope this helps you!

-Frinny
May 31 '07 #10
Adanik
1
Select list box instead of text box and choose property called row sources and choose what ever table field you like it will allow you to display multiple values from same field
Mar 18 '09 #11

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Joe Van Meer | last post: by
2 posts views Thread by .Net Newbie | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.