Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / January 2007

Tip: Looking for answers? Try searching our database.

Updating new row in DataGridView

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Curt Gough - 08 Jan 2007 21:34 GMT
I am having some trouble with updating/inserting data through a databound
DataGridView. I call the TableAdapter.Update method on the RowLeave event.
When the user tabs out of the row to the new row, the update occurs
correctly. What I want to do is fire the update whenever the user leaves the
DataGridView - clicks another field anywhere on the form.

I've tried callling the Update method on the following events: Leave,
CellValueChanged (only one visible cell in the DataGridView),
CurrentCellDirtyStateChanged, CellEndEdit. The code that calls the Update
method fires (I follow it by breaking and stepping through), but the table
is not updated using these methods (but it is on the RowLeave event so long
as the user stays in the DataGridView).

How can I call this Update method and have it actually update the data in
the table? Ideas?

Thanks for any help.
RobinS - 09 Jan 2007 01:12 GMT
The Leave event for the Grid didn't work?

What about capturing the Validate event, checking to see
if it's the Grid control that triggered it, and if so,
run the update? I think the Validate event fires whenever
someone leaves a field and goes to another one.

Robin S.
-------------------------------
>I am having some trouble with updating/inserting data through a
>databound DataGridView. I call the TableAdapter.Update method on the
[quoted text clipped - 14 lines]
>
> Thanks for any help.
Terry@Newton.ws - 30 Jan 2007 19:29 GMT
I have what appears to be the same problem.

None of the leave or validate events will fire on either the row or the cell under specific.  Unfortunately those circumstances are commonly acheived.  If the the user clicks on a control outside the grid you would expect the Leave or Validate events to fire, but when the selected control either does not gain focus the DGV control does not loose it and those eents do not fire.  Firing the events programatically does not resolve the problem.  Stting focus programmatically also does not resolve the issue, but rather causes an event to fire later for these, which if we are trying to get the contents of the current grid (for example to do a 'save') is too late.

The problemm appears to be because the last row in the DGV is new and does not exist yet in the datasource in our case.  We use a table and the DGV row count is normally one greater than the table row count, but in this case is it is 2 greater.  

Performing an endedit in the save (our case) function does not flush the row fromm the grid to the underlying table.

I am at a lose for a solution, but I thought another example of a possibly related issue with some additional observations might help.
RobinS - 31 Jan 2007 23:35 GMT
Are you calling the Validate method before calling EndEdit?

Robin S.
------------------------------
>I have what appears to be the same problem.
>
[quoted text clipped - 21 lines]
> ---
> Posted via DotNetSlackers.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.