473,837 Members | 1,469 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)
  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
(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 1136

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

Similar topics

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...
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...
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
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...
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...
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
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.
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...
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.
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: 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,...
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: 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: 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: 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
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.