473,385 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 1518
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(CancelEventArgs 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?", MessageBoxButtons.YesNo,
MessageBoxIcon.Warning, MessageBoxDefaultButton.2) == DialogResult.No))
{
e.Cancel = true;
}

base.OnClosing(e);
}

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
"Cor Ligthert" <no************@planet.nl> wrote in message news:ur**************@TK2MSFTNGP14.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
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...
4
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...
18
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...
2
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...
2
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 ...
9
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....
5
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...
9
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...

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.