-2

I want to bind complete DataTable data to RichTextBox, but i am getting only one cell by using this code below. How can i get the first row data to RichTextBox?

SqlConnection con = new SqlConnection(@"data source=CENSYS01\SQLEXPRESS; Initial Catalog=myTest; Integrated Security=True");
SqlCommand cmd = new SqlCommand("select * from student", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
richTextBox1.DataBindings.Add("Text", dt, "Sno" );
Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939

2 Answers2

1

Not sure why you want to bind a db to richtextbox, i would suggest you rather use a gridview. Its much more flexible and has a nice way of showing off the data.

Check this page, has good stuff about how to use gridviews

http://www.ezineasp.net/category/ASP-Net-C-Sharp-GridView-Control.aspx

Mana
  • 1,925
  • 6
  • 39
  • 55
0

You could try one of these options:

Community
  • 1
  • 1