Solved

c# Check for Pending Updates

Posted on 2014-12-16
6
200 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 500 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 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