VS2003
I am using a datagrid on a Windows form.
The user has 2 buttons: cancel the current changes (re-loads the dataset)
or update (updates the dataset).
The problem is that any edits in the current row are not included in the
update.
The user has to click out of that row before updating. If this is not done
and the 'current row' remains selected after the update, the user will see
the edited row and assume it has been included in the update.
I have tried moving the focus before updating and even EndEdit to try to
force the current row to accept any changes - but without success.
Has anyone got any suggestions?
Thanks in advance. 4 3450
Keith,
Can you post some of your code from the update event?
Here is the code from the form which includes the Toolbar button events and
the unsuccessful 'EndEdit'.
Private Sub dsLoad()
Me.ObjDsSupplie rList.Clear()
Me.OleDbDataAda pter1.Fill(ObjD sSupplierList.T ables(0))
End Sub
Private Sub ToolBar1_Button Click(ByVal sender As Object, ByVal e As
System.Windows. Forms.ToolBarBu ttonClickEventA rgs) Handles ToolBar1.Button Click
Dim dgtS As DataGridTableSt yle = Me.dgdSuppliers .TableStyles(0)
'complete any edits
dgtS.DataGrid.E ndEdit(dgtS.Gri dColumnStyles(M e.dgdSuppliers. CurrentCell.Col umnNumber), Me.dgdSuppliers .CurrentRowInde x, False)
Select Case ToolBar1.Button s.IndexOf(e.But ton)
Case 1
dsLoad()
Case 2
If ObjDsSupplierLi st.HasChanges() Then
Try
OleDbDataAdapte r1.Update(ObjDs SupplierList)
Catch ex As Exception
MsgBox("There were errors in the data. The table has
not been updated." & vbCr & ex.Message)
End Try
End If
End Select
End Sub
"Charlie Brown" wrote: Keith, Can you post some of your code from the update event?
Hi,
I had this problem before, and I solved it with the following procedures:
=============== ==============
Public Sub UpdateDatasourc e(ByVal OleDB As DataAdapter, ByVal grid As
GridControl, ByVal dataset11 As DataSet, ByVal TableName As String)
'Save the latest changes to the bound DataTable
Dim View As ColumnView = grid.KeyboardFo cusView
View.CloseEdito r() ' <=== VERY IMPORTANT Statement for any update
If Not View.UpdateCurr entRow() Then Return
'Update the database's table
DoUpdateTable(O leDB, dataset11.Table s(TableName))
'Update the database's table
End Sub
Public Sub DoUpdateTable(B yVal dataAdapter As DbDataAdapter, ByVal
dataTable As System.Data.Dat aTable)
dataAdapter.Upd ate(dataTable)
End Sub
=============== =============== ==
I hope this helps you.
Regards
"Keith G" wrote: Here is the code from the form which includes the Toolbar button events and the unsuccessful 'EndEdit'.
Private Sub dsLoad() Me.ObjDsSupplie rList.Clear()
Me.OleDbDataAda pter1.Fill(ObjD sSupplierList.T ables(0))
End Sub
Private Sub ToolBar1_Button Click(ByVal sender As Object, ByVal e As System.Windows. Forms.ToolBarBu ttonClickEventA rgs) Handles ToolBar1.Button Click
Dim dgtS As DataGridTableSt yle = Me.dgdSuppliers .TableStyles(0) 'complete any edits
dgtS.DataGrid.E ndEdit(dgtS.Gri dColumnStyles(M e.dgdSuppliers. CurrentCell.Col umnNumber), Me.dgdSuppliers .CurrentRowInde x, False)
Select Case ToolBar1.Button s.IndexOf(e.But ton) Case 1 dsLoad() Case 2 If ObjDsSupplierLi st.HasChanges() Then Try OleDbDataAdapte r1.Update(ObjDs SupplierList) Catch ex As Exception MsgBox("There were errors in the data. The table has not been updated." & vbCr & ex.Message) End Try
End If End Select End Sub
"Charlie Brown" wrote:
Keith, Can you post some of your code from the update event?
Thanks for your response.
However, I don't recognise GridControl or ColumnView as Controls, Classes or
Members.
Are these controls in VS 2005? I'm using VS 2003.
There doesn't seem to be the equivalent to the KeyboardFocusVi ew and
CloseEditor members in VS 2003 (which appears to be the key to including the
current row edits in the update)
...... or am I in the wrong discussion group?!!
"Moumen VB.NET 2003/2005 Developer" wrote: Hi,
I had this problem before, and I solved it with the following procedures:
=============== ==============
Public Sub UpdateDatasourc e(ByVal OleDB As DataAdapter, ByVal grid As GridControl, ByVal dataset11 As DataSet, ByVal TableName As String) 'Save the latest changes to the bound DataTable Dim View As ColumnView = grid.KeyboardFo cusView View.CloseEdito r() ' <=== VERY IMPORTANT Statement for any update If Not View.UpdateCurr entRow() Then Return 'Update the database's table DoUpdateTable(O leDB, dataset11.Table s(TableName))
'Update the database's table End Sub
Public Sub DoUpdateTable(B yVal dataAdapter As DbDataAdapter, ByVal dataTable As System.Data.Dat aTable) dataAdapter.Upd ate(dataTable) End Sub
=============== =============== ==
I hope this helps you.
Regards
"Keith G" wrote:
Here is the code from the form which includes the Toolbar button events and the unsuccessful 'EndEdit'.
Private Sub dsLoad() Me.ObjDsSupplie rList.Clear()
Me.OleDbDataAda pter1.Fill(ObjD sSupplierList.T ables(0))
End Sub
Private Sub ToolBar1_Button Click(ByVal sender As Object, ByVal e As System.Windows. Forms.ToolBarBu ttonClickEventA rgs) Handles ToolBar1.Button Click
Dim dgtS As DataGridTableSt yle = Me.dgdSuppliers .TableStyles(0) 'complete any edits
dgtS.DataGrid.E ndEdit(dgtS.Gri dColumnStyles(M e.dgdSuppliers. CurrentCell.Col umnNumber), Me.dgdSuppliers .CurrentRowInde x, False)
Select Case ToolBar1.Button s.IndexOf(e.But ton) Case 1 dsLoad() Case 2 If ObjDsSupplierLi st.HasChanges() Then Try OleDbDataAdapte r1.Update(ObjDs SupplierList) Catch ex As Exception MsgBox("There were errors in the data. The table has not been updated." & vbCr & ex.Message) End Try
End If End Select End Sub
"Charlie Brown" wrote:
Keith, Can you post some of your code from the update event?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Frnak McKenney |
last post by:
I have a (small) multi-table database application which allows
edits, print reports, and has two scrolling screen displays which
show information merged from multiple tables.
I'm having trouble with one of the scrolling displays which is
implemented as a DataGrid with several custom DataGridColumnStyles.
When the Form containing the DataGrid is made visible the initial
rows of the DataGrid's DataView source display as one might expect....
|
by: TT (Tom Tempelaere) |
last post by:
Hay there,
I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one
(I hope .NET 2.0 supplies one). I based it on this article:
http://msdn.microsoft.com/msdnmag/issues/03/08/DataGrids/default.aspx
I have a problem when there are two DataGrid's on one form, and when I
switch focus from one grid to the other. To be more precise, when I'm editing
a combo box column in one grid, and then click in the combo column of...
|
by: Jim Heavey |
last post by:
Hello, I have a datagrid that I have configured to bind
to "table1". I created and "EditItemTemplate" which is
also bound to "table1" except for two columns which I
bound to "table2" and "table3" which support
DropDownList. These table contain the list of valid
values which can be selected from the drop down list.
When a user successfully edits a line, I take the
appopriate values from the DropDownList and place those
values into...
|
by: Richard |
last post by:
I've seen articles on GotDotNet and elsewhere on how to put a ddl in a
datagrid, and have been able to implement this technique. For a new item,
among the datagrid columns there is the one ddl for the user to choose an
account description, and when the user saves, then the value is saved and
displayed in a bound column in the datagrid. So far so good.
The problem is when the user edits the line. The ddl is refreshed with all
of the...
|
by: Jan Nielsen |
last post by:
Hi
I have a parent detail relationship between two tables.
The detail records are shown in a datagrid (GridRemarks)
It is databound like this
GridRemarks.Datasource = mainDatasource ' a shortcut to
myDataSet.tblPersons.DefaultView
GridRemarks.DataMember ="tblPersons_tblRemarks" ' The name of the parent
detail relation
| |
by: Jan Nielsen |
last post by:
Hi
I asked this question some weeks ago, but have found no soluion yet, so I
try again
I have a parent detail relationship between two tables.
The detail records are shown in a datagrid (GridRemarks)
It is databound like this
GridRemarks.Datasource = mainDatasource ' a shortcut to
myDataSet.tblPersons.DefaultView
|
by: dbuchanan |
last post by:
Where is the logic error that causes the attached code to adds two rows
instead on one to the datagrid?
The code correctly update the datasource with one row, but the datagrid
gets two new rows.
What can I do to correct this?
Circumstances:
There are textboxes on the form where the users will enter data. The
|
by: julian.tklim |
last post by:
Hi,
I need to build an editable Datagrid with add & delete buttons on each
row using javascript.
DataGrid need not be pre-populated with values.
To make the thing complicated, one of the column need to be a date
picker field.
I know things will be easier with ASPX datagrid.
|
by: _MC_ |
last post by:
Hi,
I'm unable to access values in my Datagrid. Datagrid thinks it hase only 1
Cell. So here it is:
The Datagrid is binded in PageLoad, AutoGenerateColumns is false, Columns
are added on PageLoad like this:
BoundColumn Bound_Column = new BoundColumn();
Bound_Column.DataField = name; ( + HeaderText,
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |