Home > DeveloperSection > Forums > Binding data with DataGridView
John Smith

Total Post:102

Points:720
Posted on    September-29-2010 10:05 AM

 C# C# 
Ratings:


 2 Reply(s)
 1546  View(s)
Rate this:
Please let me know where I am wrong

Here binding data with datagridview control in C#

SqlConnection con = new SqlConnection("server=****\\sqlexpress; uid=sa; password=sa; database=****");

            con.Open();

            SqlDataAdapter ada = new SqlDataAdapter("select * from tableName", con);

            DataTable dt = new DataTable();

            ada.Fill(dt);

            dataGridView1.DataSource = adaa;




Uttam Misra

Total Post:125

Points:897
Posted on    September-29-2010 10:12 AM

Replace this line of code

dataGridView1.DataSource = adaa;

with

dataGridView1.DataSource = dt;   dt[DataTable name]


Modified On Sep-29-2010 10:13:05 AM

John Smith

Total Post:102

Points:720
Posted on    September-30-2010 10:59 AM

yes i missed that...thanks

Don't want to miss updates? Please click the below button!

Follow MindStick