When you close and reopen the form, the references to the ChooseFromList
and its associated DataTable
(oDataTable
) become invalid. This happens because the form's UI elements are recreated, and their internal IDs (Unique IDs) may change upon reopening. Therefore, the oDataTable
you are trying to access is not the same one that is currently active in the form.
The UniqueID
of the DataTable
may change between form instances. Instead of checking oDataTable.UniqueID
, you should check the ChooseFromList
UID provided by the event.
Replace:
if (oDataTable.UniqueID == "CFL_Item")
With:
if (oCFLEvento.ChooseFromListUID == "CFL_Item")
Before accessing oDataTable
, check if it is not null to prevent null reference exceptions.
if (oDataTable != null && !oDataTable.IsEmpty)