This is a migrated thread and some comments may be shown as answers.

Deleted event and RejectChanges

1 Answer 29 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Louis Bouchard
Top achievements
Rank 1
Louis Bouchard asked on 23 May 2010, 03:21 AM
Hello there,

I have to cancel a deleted line in the MyGirdView_Deleted (related to Referential Integrity).  The line is deleted in the Grid but not in my database (I use the RejectChanges method).  So I need to refresh my GridView.  I try the MyGridView.Rebind() to reflect the exact content of my DomainService but nothing append.  I use RadDataPager to control everthing.

This is my code :

        private void MyGirdView_Deleted(object sender, Telerik.Windows.Controls.GridViewDeletedEventArgs e)
        {
            ActionsDomainContext ctx = (ActionsDomainContext)actionsDomainDataSource.DomainContext;
            ctx.SubmitChanges(o =>
            {
                if (o.HasError)
                {
                    MessageBox.Show("Cannot be deleted", "Cancel", MessageBoxButton.OKCancel);
                    o.MarkErrorAsHandled();
                    ctx.RejectChanges();
                    MyGridView.Rebind();
                }
            }, null);   
        }


Any clue will be appreciate.  Thank you

1 Answer, 1 is accepted

Sort by
0
Louis Bouchard
Top achievements
Rank 1
answered on 23 May 2010, 04:35 PM

SOLVED.  It's working.  I have to use Load method not with my ctx but with the name of my DomainDataSource.

        private void MyGrid_Deleted(object sender, Telerik.Windows.Controls.GridViewDeletedEventArgs e)
        {
            ActionsDomainContext ctx = (ActionsDomainContext)actionsDomainDataSource.DomainContext;

            ctx.SubmitChanges(o =>
            {
                if (o.HasError)
                {
                    MessageBox.Show("Cannot be deleted (IR)", "Cancel", MessageBoxButton.OK);
                    o.MarkErrorAsHandled();
                    ctx.RejectChanges();
                    // Use directly the DomainDataSource, not the ctx... (It's refreshing automatically the GridView)
                    this.actionsDomainDataSource.Load();
                }
            }, null);
            TextBlockConsignes.Text = "Deleted...";          
        }

Tags
GridView
Asked by
Louis Bouchard
Top achievements
Rank 1
Answers by
Louis Bouchard
Top achievements
Rank 1
Share this question
or