Getting row not in table exception: This row has been removed from a table and does not have any data.BeginEdit() will allow creation of new data in this row

Hi

I have never seen this exception before and iam stucked with how to resolve this...?
Can anyone guide how i can fix this?
public decimal Sum
        {
            get
            {
                decimal mySum = 0;

                foreach( DsReconItems.MatchItemRow row in reconcileRows )
                {
                    mySum += row.Amount;   GETTING EXCEPTION HERE
                }

                return mySum;
            }
        }

Open in new window

AdnanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AdnanAuthor Commented:
i have 2 tab...one Search transactions tab, and one open transaction...when i search for some transactions and get the result, and then i switch to open transaction tab and back again i get this exception....it seems like the datatable get empety or something when i switch between two tabs... ???!
saraganiCommented:
Which UI are you working with (Winforms, WPF?)

I know for sure on WPF that when you switch tabs, the UI of the old tab get unloaded and when you return back to it, it reloads.


I can't understand the whole logic of your code without seeing it, but it must be something with the Load event.
(I can assume that you load your DsReconItems.MatchItemRow on your Load event of the UserControl/UI which is located inside the tab, am I right?)
AdnanAuthor Commented:
hi


yes man,i load my DsReconItems.MatchItemRow on Load event of the UserControl, wich is located inside the tab...????!
and iam working with WinForms, WPF!
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

AdnanAuthor Commented:
here is my code where i call tab_click event....

and at this line i call to function decimal Sum function where i get error...code above...
private void tabSrch_Click(object sender, EventArgs e)
        {
            if (showReconciled)
            {
                ReconManuallyGridView.Visible = true;
                btnReconcile.Text = GetValue("reconcile");
                ClearLeftRightPage();
                SetSelectedTab(tabButtonOpenItems);
                ShowReconciled();
            }
            if (manRecon.Diff != 0)
            {
                searchControl1.ClearControls();
                searchControl1.searchTextDecimalFieldAmount.TextBox.Text = manRecon.Sum.ToString();  I CALL TO DECIMAL Sum FUNCTIUN here....
            }

            SetSelectedTab(tabSrch);
            //ReconManuallyGridView.SendToBack();
            searchControl1.SearchDb();

        }

Open in new window

AdnanAuthor Commented:
if i change my code lines to:


                searchControl1.searchTextDecimalFieldAmount.TextBox.Text = manRecon.Sum.ToString();
                searchControl1.ClearControls();

The i stop getting this exception...but i want my data grid/dataset whatever to remeber those rows i had searched for before i swicthed to another tab and back again??!!! the state of the row is detached...?!
saraganiCommented:
I'm not entirely familiar with your code, but maybe you can load the  DsReconItems.MatchItemRow once on the Load event of the Tab, and they check if it's already loaded before clearing it or creating a new instance of it.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AdnanAuthor Commented:
oki the issue here was that i was clearing my dataset before so i get this message...i have resolved it by clearing ds after....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.