Click here to Skip to main content
15,887,999 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have a DataSet ds. I want to print the value of DataSet(ds) into a textbox as a string..
Below is my code.

C#
textBox1.Text = dt.Rows[0].ItemArray[0].ToString();


This is just displaying single row(first row)....
I want all the rows to be displayed...

What I have tried:

Please help me solve this issue.
Posted
Updated 26-May-16 20:30pm
v2
Comments
George Jonsson 26-May-16 18:53pm    
Why do this in the first place? It is not the most user-friendly way to present your data.
Maybe if you explain a bit more, there might be a better solution for what you want to achieve.
Prateek Dalbehera 31-May-16 3:11am    
Please clear that its dataset or datatable, if its datatable then you iterate through it and append the values to stringbuilder and finally, textbox.text = stringbuilder.tostring(); also u need to use text area for this. but why do u want to do like as its seems ugly practice.

You have to iterate over the rows, like using a FOR loop, and append each line to a string variable or StringBuilder (better!) and build the text yourself. There is nothing that's going to do it for you automatically.
 
Share this answer
 
How can you add all rows in single textbox ?
Do you know, dataset may contains combination of multiple tables
If there are multiple rows in dataset (forget about multiple tables) then how can show all rows in textbox and how user friendly it is ? either you need to show it in Multiline textbox or gridview or repeater control
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900