Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.