473,671 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

End Edit of a DataGrid so that it updates it’s DataSource

8 New Member
When you make changes to a DataGrid a picture of a Pencil appears on the right hand side. As I understand it, the DataSource is not updated until you move off that row and the Pencil disappears.

If one of my users were to close the form without remembering to press the “Update Database” button then the changes would be lost. So I wrote a procedure for the On Closing Event that checks for Modified rows, and if there are it prompts the user to “Update the Database”:

Expand|Select|Wrap|Line Numbers
  1.     Private Sub frmSiteInfo_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
  2.         'Problem the Is that I can't force an end to the Edit of the Datagrid. So Changes are not apparent in the table
  3.   dtgComment.EndEdit(dtgComment.TableStyles("tblComment").GridColumnStyles(dtgComment.CurrentCell.ColumnNumber), dtgComment.CurrentCell.RowNumber, False)
  4.  
  5.         'This checks whether there are changes to be made to the Database
  6.         Dim dvChangedRecord As New DataView(dtblComment, "", "", DataViewRowState.ModifiedCurrent)
  7.         If dvChangedRecord.Count > 0 Then
  8.             Dim intMsgBoxResult As Integer
  9.             intMsgBoxResult = MsgBox("Do you wish to save your changes to Comments?", MsgBoxStyle.YesNo, "You have not saved your changes to Comments")
  10.             If intMsgBoxResult = vbYes Then
  11.                 UpdateCommentsTable()
  12.             Else
  13.                 dtblComment.RejectChanges()
  14.             End If
  15.         End If
  16.     End Sub
  17.  
(You might notice that I used EndEdit, but it does not seem to have the effect I required)

This won’t work if the user fails to move off the edited record before pressing the Close button “X” at the top of the window because the changes to the DataGrid are not write to the DataGrid’s Data Source (in this case dtblComment)

I would really appreciate any suggestions!!
Jun 8 '07 #1
0 1127

Sign in to post your reply or Sign up for a free account.

Similar topics

12
2782
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option Description"></asp:BoundColumn> <asp:TemplateColumn runat="server" HeaderText="Id Type Option" "> <itemtemplate> <asp:label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "TypeOption") %>' /> <asp:label runat="server" ID="LlbTypeOption" Visible=False...
2
7812
by: Stephan Steiner | last post by:
Hi I'm using several DataTables in my program which are updated periodically. At the same I have those tables bound to DataGrids in my GUI. So far I've been doing all the processing in the same program and the speed of the processing prevented any issues when it comes to updating the GUI elements (as DataTables are changed this triggers updates in the DataGrids), but as soon as I add cpu time intensive processing options (i.e. receiving...
0
1319
by: Raed Sawalha | last post by:
Hello: I have windows application that do monitoring task, there is a thread continously running to check updates made on XML file then updates the datagrid information with new information as follows : DataSet dsUsers = new DataSet("dsUsers"); dsUsers.ReadXml(EduFilterMonitorFile); if(dsUsers.Tables.Count == 2) sbUsers.Text = "No Information avaiable - No Users in EduFilter Cache
5
12230
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. The ID is a member of the keys array. I then create a DataView dv over the table, and sort it by Display and ID column (in case of duplicate Display). I then set my DataGrid.DataSource = dv; I then load the datatable with my rows, and this is...
1
2825
by: moondaddy | last post by:
Is it possible to build a datagrid where each row in datagrid could have read/write checkboxes, textboxes and dropdownlists? Then so save the updates the user would click on a submit button and code on the server would loop through each row to capture any changed data. This would be much better for this particular case where users need to quickly review a list of data, edit values in many different rows, and then save everything in a...
3
4369
by: Tim::.. | last post by:
Can someone please tell me how I go about preselecting an item in a drop drown list when I click the Edit Command in a datagrid? I have tried the following but it doesn't work for me! I would be really grateful for any assistance! Thanks
2
1397
by: wolfgang wagner | last post by:
hi all! im trying to edit data in a datagrid (like described here: http://aspnet.4guysfromrolla.com/articles/071002-1.aspx) but if i click the edit button i get the following error invalid attempt to FieldCount because datareader is already closed (sorry, this error message is translated from german) when trying to do the databinding.
3
1569
by: Tim McKinney | last post by:
I have a read-only datagrid that I use to display a heirarchal model of three tables (The example I am setting up uses the Customer, Orders, and Order Detail tables from the northwind database). I load the three tables into a single dataset and then create the relationships. What I want to do is use a separate grid that would display the selected record from the datagrid only, but still would be bound to the dataset. The first grid...
2
2846
by: Peter | last post by:
ASP.NET 2003 In the DataGrid how do I select current cell value in the dropdown box when I click on the edit link, currently when I click on the edit link in the DataGrid the dropdown box appears in the cell, but allways the first item in the dropdown box is shown not the current cell value? How do I make the current value in the cell automaticaly be selected in the dropdown box.
0
8478
marktang
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...
0
8397
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8821
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 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...
1
8599
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8670
tracyyun
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...
0
7439
agi2029
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...
1
6230
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 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...
1
2813
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1810
bsmnconsultancy
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...

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.