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.

Here is the code:
.
.
.
If MessageBox.Show(mensaje, "Actualizo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.Yes Then
If rdbAumento.Checked Then
variacion = Convert.ToInt32(txPorcentaje.Text)
For i = 0 To gridPrecios.Rows.Count - 2
gridPrecios.Item(5, i).Value = (gridPrecios.Item(5, i).Value * (100 + variacion) / 100)
Next
Else
variacion = Convert.ToInt32(txPorcentaje.Text)
For i = 0 To gridPrecios.Rows.Count - 2
gridPrecios.Item(5, i).Value = (gridPrecios.Item(5, i).Value * (100 - variacion) / 100)
Next
End If
End If

If MsgBox("Desea guardar los cambios realizados?", MsgBoxStyle.Exclamation + MsgBoxStyle.YesNo, "WARNING") = MsgBoxResult.Yes Then
da.Update(ds, "datos")
Else
'This is the line that fails upon 2nd execution:
gridPrecios.DataSource = dsrestore.Tables(0)
End If

Else
.
.
.

Please, remember this works OK if user denis once. What am I missing regarding DataSources or its Tables? Is there anything like .Redraw?

Btw, I tried update, refresh and I also used a sleep function (this helped me a few times back in VB6...).

Thanks in advance!