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

Howdy, Stranger!

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

Categories

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

mabilalmirzamabilalmirza Posts: 12Member
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

[code]
Imports System.Data
Imports System.Data.SqlClient
[hr]
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
[hr]
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
[hr]
Private Sub BindFields()

'Clear all previous DataBindings
txtProductTypeID.DataBindings.Clear()
txtProductTypeName.DataBindings.Clear()

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

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

'Fill Data
FillDataSetAndView()

'Bind Fields
BindFields()

End Sub

End Class
[/code]
Sign In or Register to comment.