Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

c# Check for Pending Updates

Posted on 2014-12-16
6
Medium Priority
?
252 Views
Last Modified: 2014-12-16
How do I recognize if a record has updates pending? I want to determine this before allowing the user to move to another record & request that they commit the changes.

I have a c# 4.5 windows form with a Dataset, BindingNavigator, BindingSource, & TableAdapter all being used to bind the data to the form objects. Record Navigation is provided by click events on the BindingNavigator menu.
0
Comment
Question by:Lensolo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
6 Comments
 
LVL 34

Accepted Solution

by:
it_saige earned 2000 total points
ID: 40502851
If you are bound to the DataRow, then you can use the DataRow.RowState property to determine the row state.

http://msdn.microsoft.com/en-us/library/system.data.datarow.rowstate(v=vs.110).aspx

To that end, you can bind to the RowChanged event on the DataTable object when you are Binding so that you can detect row changes and act appropriately.

http://msdn.microsoft.com/en-us/library/w9y9a401(v=vs.110).aspx

-saige-
0
 

Author Comment

by:Lensolo
ID: 40502933
What I am having a hard time doing is capturing the DataTable event. On the form load, I had this entry:

 
private void TestForm_Load(object sender, EventArgs e)
{
this.TableAdapter.Fill(this.DataSet.TableName);
}

Open in new window

I changed this to the following:
private void TestForm_Load(object sender, EventArgs e)
{
this.TableAdapter.Fill(this.DataSet.TableName);
this.DataSet.TableName.RowChanging += new DataRowChangeEventHandler(Row_Changing);
}

private static void Row_Changing(object sender, DataRowChangeEventArgs e)
 {
     MessageBox.Show("Row_Changing Event kicked off");
 }

Open in new window


I have not done this before, but it seems like it should work, however I never get a message when navigating between the rows.
0
 

Author Comment

by:Lensolo
ID: 40502980
Whoops Sorry. The row changing event kicks off when I try to leave a row that has a change on it. I thought it meant just when you leave a row.

MSDN Description of RowChanging: "Occurs when a change has been submitted for a DataColumn value or the RowState of a DataRow in the DataTable."

So far this seems to work like a champ on identifying when a change occurred. I need to play around with it some, but this may work.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Lensolo
ID: 40502989
This causes other issues at present. Let me play around with the suggested routine & see if I can get this to work.
0
 

Author Comment

by:Lensolo
ID: 40502995
I see you suggested RowChanged. I'll try to use this instead.
0
 

Author Comment

by:Lensolo
ID: 40503086
This works. It gave me a surprise in that it is called for every row in the dataset during the Dataset.AcceptChanges(), but it makes sense. You just don't want to use this to call a save routine. Thanks!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question