If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

[RESOLVED] DataGridView update is ok, second update fails.

Hi!

If you see some ugly coding, do let me know. I am beginning to work with .NET technology after several years of VB6 and C++ and I want to learn as fast as possible.

My problem is with a DGV. It shows the prices of several store items, and I intend to let the user modify those prices by entering a % in a textbox (radio button states if that % is positive or negative) or by editing cell by cell manually.

As editing prices is kind of sensitive, what I do is loop through the DGV, add or substract the % engtered in the corresponding column and ask for a confirmation after whole DGV loop is done. If user agrees, DB is updated with new values. No problem here.

If user denies (in case he/she made a mistake), I restore grid's DataSource to a copy I made before calculating new percentages and this automatically refreshes my grid to its original state.

The issue is that if a user denies the operation for a 2nd time, this 2nd execution of the code fails at showing the original values, disabling the pseudo-rollback function.

Re: DataGridView update is ok, second update fails.

Thanks for your reply!

That code is executed in a _Click event.

The user clicks the radio button to select increase or decrease of prices, enters a number in a textbox and clicks a button that triggers this code. Grid is updated with new values and shown automatically.