Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
RowChanged Event Class
Message
 
À
07/10/2009 21:08:01
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01428065
Message ID:
01428279
Vues:
29
Thanks Bonnie!

I thought I heard here that you wee out of work?




>In addition to what Viv said, I'd like to add that you don't need to do this EndEdit() every time a row of data changes. In fact, most of the time the EndEdit() gets done properly anyway. Instead, I'm sure you remember seeing my post about this at one time or another (I've posted it many times, but I'll repeat it here because I don't feel like searching for one of my old posts). Note that you only call this when you're ready to save the changed data (prior to checking for .HasChanges()) and also note that it will only commit (run the .EndEdit() on) the Proposed changes.
>
>Data in a DataRow has several different versions. First, there's the original version. Then, when it's being edited, it has a Proposed version and once it's done being edited, that becomes the Current version. Sometimes when editing, the row is left in the Proposed state and the Edit needs to be ended programmatically.
>
>Here's a method I *always* call before I attempt to check for .HasChanges() before saving 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();
>			}
>		}
>	}
>}
>
>
>~~Bonnie
>
>
>
>
>>Instead of calling this:
>>
>>
>>private void CommitChanges(DataSet ds)
>>{    
>>	foreach (DataTable dt in ds.Tables)    
>>	{        
>>		foreach (DataRow dr in ds.Tables)        
>>		{            
>>			dr.EndEdit();        
>>		}    
>>	}
>>}
>>
>>
>>
>>why not do this when I create the table:
>>
>>
>>dt.ColumnChanged += new DataColumnChangeEventHandler(dt_ColumnChanged);
>>
>>
>>then in the event do this:
>>
>>
>>void dt_ColumnChanged(object sender, DataColumnChangeEventArgs e){    e.Row.EndEdit();}
>>
>>
>>This would fire each time the user changes a bound item on a form, wouldn't it? If so, them I'm assured that the table's rowstate
>>would always show modifed for changed items.
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform