Bind GridView with BindingSource Class

Posted by Lakhangarg under VB.NET category on | Views : 4997
First Steps is to create the object of BinduingSource Class As:
Dim bsGrid1 As New BindingSource

Get the data into a dataset from database using SqlDataAdapter.
DataSet dsMyData AS New DataSet()
dsMyData={Method to Get Data From database}

Now use the following code to bind the grid through binding source:
dgvMyGrid.DataSource = bsGrid1 
bsGrid1 .DataSource = dsMyData
bsGrid1 .DataMember = "Table1" ' Table Name

dgvMyGrid.BindingContext = Me.BindingContext()

Thanks & Regards
Lakhan Pal

Comments or Responses

Login to post response