1

I want to bind datagridview in windows application with dynamically changed datatable.

I have windows form with two textboxes, one for connection string with sql server and the other for sql query string. I just want to display data in datagridview in order to see data. I don't need anything fancy, just to read result of sql query.

Thanks in advance!

DP

Draško
  • 2,119
  • 4
  • 41
  • 73

2 Answers2

2

Just assign the DataTable to the Datasource property of the DataGridView.

leppie
  • 115,091
  • 17
  • 196
  • 297
0

Once you have the datatable just do the following:

myDataGrid.DataSource = myDataTable;
myDataGrid.DataBind();

That should be all you need to do.

Giles Smith
  • 1,952
  • 15
  • 17