473,800 Members | 2,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forcing Data to be written to DataSet

The issue: I have a grid which has a dataset as the datasource.

If a user enters data in a textbox on the grid and then clicks on the close
button of the form (the red X in the upper right corner), no events fire for
the grid or the control that the user was typing in.

The closing event of the form does fire, and I check there to see if any
changes need to be saved. If the user changes rows in the form, the typed
data is transmitted to the dataset. However, if the user goes directly for
the close button, the data is not transmitted to the dataset, and the dataset
does not know there are changes to be saved.

So the question is, how to force the events to fire? In another language,
we would use the SetFocus() method to set the focus to a control on the grid
which would fire the necessary events. But how do I do this in C#?

Greg
--
Greg Gum
Nov 17 '05 #1
2 1538
Greg,

The problem is that you do not know if the user want to update or not.
However let assume that that is your approach that there will be an update.

Than you can use the closing event to catch that clicking the X.
(you need than the endcurrentedit to force a row change)

http://msdn.microsoft.com/library/de...tedittopic.asp

I hope this helps,

Cor
Nov 17 '05 #2
I'd like to add to Cor's explaination:

The closing event is cancellable, so it may be more appropriate to prompt the user to save changes instead of assuming they want the
changes saved.

protected override void OnClosing(Cance lEventArgs e)
{
// Implement a method to check if the form has changes, named "IsDirty"
if (IsDirty() &&
MessageBox.Show (this, "Save Changes",
"You have unsaved changes.\r\nAre you sure you want to close the application?", MessageBoxButto ns.YesNo,
MessageBoxIcon. Warning, MessageBoxDefau ltButton.2) == DialogResult.No ))
{
e.Cancel = true;
}

base.OnClosing( e);
}

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"Cor Ligthert" <no************ @planet.nl> wrote in message news:ur******** ******@TK2MSFTN GP14.phx.gbl...
Greg,

The problem is that you do not know if the user want to update or not.
However let assume that that is your approach that there will be an update.

Than you can use the closing event to catch that clicking the X.
(you need than the endcurrentedit to force a row change)

http://msdn.microsoft.com/library/de...tedittopic.asp

I hope this helps,

Cor

Nov 17 '05 #3

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

Similar topics

0
5414
by: sedefo | last post by:
I ran into this Microsoft Patterns & Practices Enterprise Library while i was researching how i can write a database independent data access layer. In my company we already use Data Access Application Block (DAAB) in our .Net projects. We use SqlHelper in SQL based projects, and OracleHelper in Oracle based ones. OracleHelper was not published officially by Microsoft as part of the DAAB but it was given as a helper code in a sample .Net...
4
555
by: Simon | last post by:
Hi all, I have a process, where I take a dataset from an SQL call, and need to write an XML file from that dataset. The data set can contain 10's of tables, each with 100's of rows, and I have no way of knowing what the tables are, or what they contain. I am currently using the Dataset.WriteXML method passing an XMLWriter.
18
1540
by: MuZZy | last post by:
Hi, I got a situation here :) an dwonder if someone can help me. I have an MDI app and say, the child form has a button, clicking on which calls a database transaction - grabbing a lot of tables to the form's TDataSet variable. One transaction grabs about 10 or more Mb of data. If i do several transactions, the memory occupied by the app goes say goes up to 180Mb - i watch it in Task Manager. Now i close the child form, and...
2
2215
by: headware | last post by:
I'm relatively new to ASP.NET and ADO.NET, but I have a basic design question regarding the use of web services and APS.NET applications. Right now we have an application that uses web services to access the database layer. However, the code works in a pretty cumbersome and ungeneric way. Basically every query, update, and insert has its own function. So you see a lot of functions like webService.InsertCustomer(name, age, phone); or...
2
4595
by: Chris Langston | last post by:
I have a Web Server running IIS 5 or 6 on Windows 2K and Windows 2003 Server that is experiencing strange shutdown problems. We are using ASP.NET v1.1 and our application is written in VB.NET Here's the scenario: 1. .NET Windows Client on a remote machine makes a web service call to update tables on a Web Server running SQL Server 2000. 2. The Update is updating about 1000 - 3000 records doing simple update statements like "Update...
9
2066
by: Brad | last post by:
I have written some code to manipulate data/records in a MASTER (order header) and DETAIL (order details) tables. What I have written is too extensive to post but essentially trying to: 1. Assign to a datarow (dr1) the first record of the MASTER table 2. Assign to another datarow (dr2) the second record of the MASTER table 3. If dr1.field1 = dr2.field1, then proceed, otherwise do stop 4. Assign to a third datarow (dr3) the first record...
5
1630
by: Brian P. Hammer | last post by:
I have data from multiple SQL tables, some of the tables will only have one row, while others multiple rows. I load a bunch of data from the various tables and add them to a third party grid. With some of the rows, I perform calculations on some of the rows and all this is loaded into the grid as well. I am trying to figure out the best way to store all this data so that it is easier to work with and perform calculations as users edit the...
9
4029
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New DataTable("SliceInfo") Dim tblSliceRatings As New DataTable("SliceRatings") '.... All the adding datacolumns, datarows, etc. goes here.. DatasetInit.Tables.Add(tblSliceInfo)
0
9690
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
9550
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,...
1
10250
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
10032
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
6811
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();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.