Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


How to use Binding Navogator with DataSet and/or DataView object?

mabilalmirzamabilalmirza Member Posts: 12
I retrieved records in DataSet object and got a table in DataView object from the DataSet object. I bound Text boxes with DataView object. Everything is working correctly.

But now I want to use Binding Navigator object to navigate between records of DataView object. How can I use it?

One way is to use Wizard, but I don't want to use wizard.

I have following controls on the form "frmCategories"

[b]BindingNavigator[/b]: bnvProducts
[b]TextBox[/b]: txtProductTypeID
[b]TextBox[/b]: txtProductTypeName

I have the following coding

Imports System.Data
Imports System.Data.SqlClient
Public Class frmCategories

'Query String
Dim strQuery As String = "SELECT * from Product_Type"

'Sql Objects
Dim objConnetion As New SqlConnection("Data Source=.;Initial Catalog=BE;Integrated Security=True")
Dim objDataAdapter As New SqlDataAdapter(strQuery, objConnetion)

Dim objDataSet As DataSet
Dim objDataView As DataView
Private Sub FillDataSetAndView()

objDataSet = New DataSet

'Fill Data Set
objDataAdapter.Fill(objDataSet, "Product_Type")

'Getting ProductType table from DataSet in DataView
objDataView = New DataView(objDataSet.Tables("Product_Type"))

End Sub
Private Sub BindFields()

'Clear all previous DataBindings

'Bind to DataView object
txtProductTypeID.DataBindings.Add("Text", objDataView, "Product_Type_id")
txtProductTypeName.DataBindings.Add("Text", objDataView, "Product_Type_Name")

End Sub
Private Sub frmCategories_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

'Fill Data

'Bind Fields

End Sub

End Class
Sign In or Register to comment.