Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Ctrl+S is DataGrid does not save data
Message
From
13/01/2007 18:23:54
 
 
To
03/01/2007 15:23:44
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
C# 1.1
Miscellaneous
Thread ID:
01181178
Message ID:
01185400
Views:
17
Bonnie,

I found that when I press Save button in toolbar data is not saved.
To fix this I added the following lines to form Save() method:
if (ActiveControl != null && ActiveControl is DataGridTextBox)
  ((DataGrid)((DataGridTextBox)ActiveControl).Parent).EndEdit();
If current control is outside grid I think that data is still not refreshed.
How to implement refresh for every active control when Save button is pressed ?

DataGrid EndEdit() method contains your recommendation:
((CurrencyManager)BindingContext[
	DataSource, DataMember]).Refresh();
>Call it in your BizObject .Save() just before you pass the DataTable to the DataAccess .Save() method.
>
>I never use the .EndCurrentEdit() method ... I have seen problems with it in the past. I can't remember exactly when it has problems, but I resolved any problems there might be by not using it at all ... and calling my CommitProposedChanges() method instead.
>
>~~Bonnie
>
>
>
>>Thank you. I will try it.
>>
>>From where I shoult call this method: from DataGrid class, from form Save() method, from BO Save() method or from data access object Save() ?
>>
>>In my first sample I called currency manager EndCurrentEdit() method from processcmdkey().
>>
>>I read from help that EndCurrentEdit() must edit editing. Why EndCurrentEdit() is not sufficient for this ?
>>
>>
>>>I have forgotten completely about the .EndEdit() ... I bet you anything that that's what you need. Silly me!! =0)
>>>
>>>In debugging, the DataTable appears to have the correct value in it's DataColumn, however the DataRowVersion is still probably Proposed for that Row.
>>>
>>>I always call the following method before I do any saving:
>>>
>>>
>>>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();
>>>			}
>>>		}
>>>	}
>>>}
>>>
>>>
>>>Try adding this method and then call it in one of your Save() methods ... I'm almost 100% certain that this is where your problem is.
>>>
>>>~~Bonnie
>>>
>>>
>>>
>>>>Bonnie,
>>>>
>>>>I have 3 different classes containing Save() method:
>>>>
>>>>form class Save() - called without parameters from grid. It calls form business object Save() method without parameters.
>>>>
>>>>business object Save() - called without parameters from form. It calls data access object Save() by passing its DataTable and some other parameters you see to data access object.
>>>>
>>>>There exist only one copy of DataTable in my application. This datatable lives in business object and its references are set as grid datasource and passed to data access object Save() method.
>>>>Also, when I press down arrow key before Ctrl+S, save work OK.
>>>>So I do'nt have duplicate datatables.
>>>>
>>>>I can send the whole code to you if you are interested.
Andrus
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform