Directly Binding Dataset with Datagrid View

  • Home
  • Blog
  • Directly Binding Dataset with Datagrid View

With windows forms 2.0 you can directly bound the datagrid with dataset.For example,

your dataset name is ‘dt’

First fill your dataset with data.

Then select datagridview and create the columns and in the datamember property of each give the name of column you want to bind.

just write the following code.

For example you datagrid code is dg

dg.DataSource=dt;

dg.Refresh();

That’s it you have bound the datagrid with dataset