Showing posts with label DataSet. Show all posts
Showing posts with label DataSet. Show all posts

Monday, July 21, 2008

How to bind a DataSet to a DataGridView, a DataGrid?

A DataSet is memory resident data in DataTables in the DataTables collection. Each table is known by its name.

Let us say a DataTable named "MyTable" in a DataSet called "MyDs" needs to be bound to a DataGrid or a DataGridView controls. Then the following code does this binding:

DataGridView1.DataSource=MyDs.Tables("MyTable")




and for a Datagrid it will be,

DataGrid1.SetDataBinding(MyDs,"MyTable")