Tuesday, December 11, 2007

How to populate your DataGrid

How to populate your DataGrid

Step 1

To populate your Dataset, create another Button on your form. When we click on it, your DataSet will be populated and then it will be reflected in your DataGrid.

Step 2

Create a button with its text Populate and then double click on it to go to Code window.

Step 3

We will use DataAdapter method called Fill() to populate our data in the datagrid.

The method is shown below.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

OleDbDataAdapter1.Fill(DataSet11)

End Sub

Dataset11 is the name of our dataset given earlier.

Step 4

The output result when you click on Populate button.

No comments: