Doing some extra task while saving databind Controls in VB.Net 2005 ?

L

Luqman

I have created a form using Data Sources in VB.Net 2005, and Binding
Navigator, even I did not write a single line of code and data is
displaying, saving, deleting perfectly with the click of buttons on Binding
Navigator.

Now, what I want, that if the user clicks on the Save Button of Binding
Navigator, one field of that table should be saved with Current Date and
Time.

Do I need to use BuyerBindingSource, BuyerTableAdapter or dsBuyer (typed
dataset).

How can I do so? Any example will be highly appreciated.

Best Regards,

Luqman
 
K

Ken Tucker [MVP]

Hi,

You can get the current datarow this way

Private Sub ProductsBindingNavigatorSaveItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ProductsBindingNavigatorSaveItem.Click

Me.Validate()

Me.ProductsBindingSource.EndEdit()

Dim dr As DataRow =
Me.Inventory_Control1DataSet.Products.Item(Me.ProductsBindingSource.CurrencyManager.Position)

MessageBox.Show(dr.Item(0).ToString)

'Me.ProductsTableAdapter.Update(Me.Inventory_Control1DataSet.Products)

End Sub



Ken
 
J

Jim Hughes

You can also use the new (in 2005) Current property

Private Sub ProductsBindingNavigatorSaveItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ProductsBindingNavigatorSaveItem.Click

if Me.ProductsBindingSource.Current Is Nothing Then Exit Sub

Me.Validate()

Me.ProductsBindingSource.EndEdit()

Dim dr As DataRow = CType(Me.ProductsBindingSource.Current, DataRow)

MessageBox.Show(dr.Item(0).ToString)

'Me.ProductsTableAdapter.Update(Me.Inventory_Control1DataSet.Products)

End Sub
 
L

Luqman

Hi,

Ok, I understood, is it possible to use Field Names with Data Row.

for example:

Dim dr As DataRow = CType(Me.ProductsBindingSource.Current, DataRow)
dr.ProductID=123
dr.ProductName="ABC"
Me.ProductsBindingSource.EndEdit()
Me.ProductsTableAdapter.Update(Me.Inventory_Control1DataSet.Products)

Best Regards,

Luqman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top