This question is locked. New answers and comments are not allowed.
Hello everyone,
Well, it's wokring but I need explanation or a better way to achieve this. When I add a new record in my RadGridView, I have to display some default values.
So, I have this code in the AddingNewDataItem event of the RadGridView
And it's working fine (note that I use Entity Framework like DomainService.cs and DomainService.metadata.cs on server side)
And in the RowEditEnded this code :
In fact without the line
RadDomainDataSourceEtapesAvantPendantApresEntree.DataView.Add(e.NewData);
the ctx.SubmitChanges never append because HasChanges (of ctx) is always False.
So, to force it, I have to add by code the new information (e.NewData).
After, that, my new data appear two time in the RadGridVIew, I have to Load the DomainDataSource :
RadDomainDataSourceEtapesAvantPendantApresEntree.Load();
And then, I see my new data in just one row.
Any idea to this more nicely?
Have wonderful day.
Well, it's wokring but I need explanation or a better way to achieve this. When I add a new record in my RadGridView, I have to display some default values.
So, I have this code in the AddingNewDataItem event of the RadGridView
private void RadGridViewEtapes_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e) { e.NewObject = new myentity.Web.Etapes { NoEtapeClient = 1, NoTypeEtape = 1 }; }And it's working fine (note that I use Entity Framework like DomainService.cs and DomainService.metadata.cs on server side)
And in the RowEditEnded this code :
private void RadGridViewEtapes_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e) { if (e.NewData != null) { if (e.EditAction == Telerik.Windows.Controls.GridView.GridViewEditAction.Commit) { RadDomainDataSourceEtapesAvantPendantApresEntree.DataView.Add(e.NewData); etapesavantpendantapresentreeDomainContext ctx = (etapesavantpendantapresentreeDomainContext)RadDomainDataSourceEtapesAvantPendantApresEntree.DomainContext; ctx.SubmitChanges(ResultatOperation => { if (ResultatOperation.HasError) { ResultatOperation.MarkErrorAsHandled(); ctx.RejectChanges(); } else { RadDomainDataSourceEtapesAvantPendantApresEntree.Load(); } }, null); } } }In fact without the line
RadDomainDataSourceEtapesAvantPendantApresEntree.DataView.Add(e.NewData);
the ctx.SubmitChanges never append because HasChanges (of ctx) is always False.
So, to force it, I have to add by code the new information (e.NewData).
After, that, my new data appear two time in the RadGridVIew, I have to Load the DomainDataSource :
RadDomainDataSourceEtapesAvantPendantApresEntree.Load();
And then, I see my new data in just one row.
Any idea to this more nicely?
Have wonderful day.