Ok, have done.

The problem was that immediately before calling the function, I needed to refill the dataset with the dataadapter. Otherwise, for some still unknown reason, it lost its records when the SelectedIndexChanged event occured.