Unable to locate newly added record in data table

I'm trying to fill some columns in a DataTable before sending it to the table adapter for update.

So, I have a databindingSource, a typed Dataset, and a table adapter.
I also have some textboxes on a Windows Forms which fill most of the columns, but some columns not shown need to be added by some calculated values.

I create a new row by calling:

which clears the textboxes so I can start typing.

Then I have a "Save" button with this code:

           int index = myDataSet.myTable.Rows.Count;

            myDataSet.myTable[index].myColumn = SomeCalculatedValue();


Open in new window

if I debug, I notice that Rows.Count didn't increase after I called the bindingSourceMain.AddNew();
But this code works with other window form and data in which all columns are filled by user.

I also tried this, as suggested in MSDN

        MyDataSet.MyTable row = myDataSet.myTable.FindByMyPrimaryKey("hardcoded primary key");

        if (row != null)
            row.myColumn =  SomeCalculatedValue();

Open in new window

For testing, I hardcoded the value of the newly added record, just for testing so, I typed the same value as the "Find" method received.
This always return a null object. It can't find the newly added record.

I must be missing something obviuos.... I'm new on VS/C#.

How do I change column values in the record that is being added?
Who is Participating?

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

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.

Sudhakar PulivarthiProject Lead - EngineeringCommented:

Please check whether the item is added to the list AddNew by handling ListChanged event.

Additionally, pls provide the code sample for further dig down & to replicate and check

fischermxAuthor Commented:
After some testing, I  get to have the current row from the bindingSource.

This code is the one that worked:

            DataRowView drv = (DataRowView)bindingSourceMain.Current;
            myDataSet.MyTableRow currentRow =  (DataRow)drv.Row;

Now I can handle my values :
           currentRow.MyColumn1 = myValue;

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
fischermxAuthor Commented:
I'm not sure if that's the only way to do it.
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
.NET Programming

From novice to tech pro — start learning today.