Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Check if data has been changed
Message
From
31/10/2007 22:12:53
 
 
To
31/10/2007 22:04:07
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01265117
Message ID:
01265589
Views:
10
Thank you Bonnie. This is something I have been playing with in C# recently so the timing of your response was perfect.



>Hey Tracy,
>
>>Does EndEdit have to be explicitly called or when is it called automatically by the framework or the lostfocus of the control or where? I'm not sure what to call everything in C# yet so pardon my ignorance.
>
>Most of the times it's not an issue because the .EndEdit() is usually automatically handled by .NET (but it only takes one episode of loss of data for your users to start screaming at you <g>)... typically this uncommitted proposed change happens when a change is made and, as in Eduardo's example, the user hasn't moved to another row (like in a Grid). I don't know if it consistently misbehaves or only sometimes.
>
>Bottom line, if you commit the Proposed changes (by calling that method I posted) prior to trying to save your Data to your backend database, then you'll be fine.
>
>~~Bonnie
>
>
>
>
>>
>>
>>>Hi Eduardo,
>>>
>>>>It works fine if I change record. Dataset.Haschanges(), seems to do the same.
>>>>But for it to work the user has to move from the record. If he makes modifications to the data and close the form, Rowset or Haschanges are not aware of the change.
>>>>What I am trying to do is Enable a save button from my datanavigator as soon as the user modifies a field in the form.

>>>
>>>There's a little "gotcha" with this, and it's caused when the data in a row has been left in a Proposed state.
>>>
>>>Data in a DataRow has several different versions. First, there's the original version. Then, when it's being edited, it becomes a Proposed version and once it's done being edited it becomes the Current version. Sometimes when editing, the row is left in the Proposed state and needs to be ended.
>>>
>>>Here's a method I *always* call before I attempt to save data:
>>>
>>>
>>>protected virtual void CommitProposedChanges(DataSet ds)
>>>{
>>>	if (ds == null)
>>>		return;
>>>
>>>	for (int nTable = 0; nTable < ds.Tables.Count; nTable++)
>>>	{
>>>		for (int nRow = 0; nRow < ds.Tables[nTable].Rows.Count; nRow++)
>>>		{
>>>			if (ds.Tables[nTable].Rows[nRow].HasVersion(DataRowVersion.Proposed))
>>>			{
>>>				ds.Tables[nTable].Rows[nRow].EndEdit();
>>>			}
>>>		}
>>>	}
>>>}
>>>
>>>
>>>Without calling the above method, .HasChanges() could return a false when in fact there is a Proposed change just waiting to be committed.
>>>
>>>~~Bonnie
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform