Home > DeveloperSection > Forums > Bind to datagridview
Ankit Singh

Total Post:341

Points:2389
Posted on    January-22-2014 11:14 PM

 C# C# 
Ratings:


 1 Reply(s)
 684  View(s)
Rate this:

How can i bind data to datagridview?

DataTable table = new DataTable();

string pot = "Provider=Microsoft.Ace.OLEDB.12.0; Data Source = " + textbox_path.Text + ";Extended Properties=\"Excel 8.0; HDR=Yes;\";";

OleDbConnection pove = new OleDbConnection(pot);

OleDbDataAdapter myDataAdapter = new OleDbDataAdapter("Select * from [" + textbox_sheet.Text + "$]", pove);

DataTable dt = new DataTable();

myDataAdapter.Fill(dt); /* napaka | oldedb driver ? :O*/

dataGridView1.DataSource = dt;



Pravesh Singh

Total Post:411

Points:2881
Posted on    January-23-2014 12:11 AM

Hi Ankit,

Add dataGridView1.DataBind(); after dataGridView1.DataSource = dt;.


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

Follow MindStick