473,398 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Update a dataset bound to a grid

Hello,
I have a problem whereby I wish to update a dataset bound to a datagrid without the user having to click on the next row of the grid to initiate an update.
I have the following event code for my grid

Private Sub dgMyDatagrid_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgMyDatagrid.CurrentCellChanged

AddHandler dsOrders.Tables.Item("Orders").ColumnChanged, New DataColumnChangeEventHandler(AddressOf Order_Changed)

Call UpdateDataSet(dsOrders, "Orders", MyOrderAdapter)

End Sub

I have the handler for the dataset column change as below

Private Sub GableLadder_Changed(ByVal sender As Object, ByVal e As DataColumnChangeEventArgs)

Call UpdateDataSet(dsOrders, "Orders", MyOrderAdapter)

End Sub
Private Sub UpdateDataSet(ByRef Mydataset As DataSet, ByVal strtable As String, ByVal Myadapter As SqlDataAdapter)
Dim objCommandBuilder As New SqlCommandBuilder(Myadapter)

Myadapter.Update(Mydataset, strtable)

End Sub

The Handler is called when a single column is changed but the underlying dataset is only changed when you click on the row above or below in the datagrid.

How can I get the datasource to update to the database without the user having to click on the next row.

Thnx in advance
Geraldine

Nov 20 '05 #1
3 1264
Cor
Hi Geraldine,

I think you have more code than needed now, but add this somewhere before
the update

DirectCast(BindingContext(dsOrders.Tables(0)),
CurrencyManager).EndCurrentEdit()

I think that your problems are than gone?

Cor
Nov 20 '05 #2
Hi Cor
Thanx a lot, that works a treat, your'e a sta

Geri

----- Cor wrote: ----

Hi Geraldine

I think you have more code than needed now, but add this somewhere befor
the updat

DirectCast(BindingContext(dsOrders.Tables(0))
CurrencyManager).EndCurrentEdit(

I think that your problems are than gone

Co

Nov 20 '05 #3
"Geraldine Hobley" <an*******@discussions.microsoft.com> wrote in message news:<85**********************************@microso ft.com>...
Hi Cor,
Thanx a lot, that works a treat, your'e a star

Geri x

----- Cor wrote: -----

Hi Geraldine,

I think you have more code than needed now, but add this somewhere before
the update

DirectCast(BindingContext(dsOrders.Tables(0)),
CurrencyManager).EndCurrentEdit()

I think that your problems are than gone?

Cor


Can you guys help me as well for my post thread "Please help in
Update---Newbie question ".
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: PAUL EDWARDS | last post by:
I have a windows form that is bound to a datatable. In VB6 I could just update the field contents and it would be updated in the database, however if I update the text property of the control from...
1
by: Darryn | last post by:
Hi I am having a few problems with one of my forms... I have a data grid bound to a dataset using a currencymanager and it's all working fine. However when i edit or change any of the data in...
13
by: abdoly | last post by:
i wrote a code to update datagrid with the datagrid updatecommand but i cant get the updated values after being update that is the code private void DataGrid1_UpdateCommand(object source,...
1
by: Marisha | last post by:
Hi Guys, I have some question, I have datadrid that bound to dataset,the data in data set filled from text file (not from database) User may update some data in datagrid,then I need to update...
4
by: steroche | last post by:
I would REALLY appreciate help please please please! Im sure it is probably blindingly obvious to most of you but I am totally in the dark here!I am lost - i thought i had finally figured out this...
6
by: Frank | last post by:
Hopefully this is the correct group for this message. My previous post to (I assume) a non-.net group was not welcomed. I have a form with 7 text boxes that are all bound to fields of a...
9
by: jaYPee | last post by:
I have search a lot of thread in google newsgroup and read a lot of articles but still i don't know how to update the dataset that has 3 tables. my 3 tables looks like the 3 tables from...
9
by: Geraldine Hobley | last post by:
Hello I'm getting the above mentioned error in my applicatio I have a datagrid bound to a datasource like s MyDatagrid.DataSource = Mydataset.Tables(Order) - this all works fine However I...
13
by: shookim | last post by:
I don't care how one suggests I do it, but I've been searching for days on how to implement this concept. I'm trying to use some kind of grid control (doesn't have to be a grid control, whatever...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.