C# - DataTables - Column is of Type Control - Export to XML

300 Views Asked by At

QUESTION: Is there a way to export a DataTable to XML when the DataTable has a Column of type Control. I get an error stating that the controls cannot be serialized. I have read up on the whole concept of serialized and DataContacts from various sources but I am still thinking there may be a much easier solution at hand that I am over looking.

BACKSTORY: I have a C# application that I am creating, the controls of the application are recycled between different views(i.e. When you load one "view" the application uses the same objects those objects then carry out different tasks, like for instances a button object named 'abutton' may be used to submit a form in one view but when in another view it may be used to save the document). To make this ever more complicated the controls are disabled once used but only within that particular "view" to stop me from doing the same thing twice. The controls and whether they are enabled is kept track of by a DataTable I create for each view. Once the view is selected the application loads the view then uses the DataTable for that view to determine which controls have been disabled. The DataTables for each view have the following Columns: ObjectName - Name of the Object Control - This is of Control type and the actual object is stored in this column Enabled - Boolean value that reflects whether the object is enabled, the default is true

Having the Control Type Column and saving the object to it makes it much easier when traversing through the DataTable to enable/disable the controls for that particular view, I know that I could take out the Control column and work around it but I really do not want to have to do that if there is a simple way to export the XML file.

0

There are 0 best solutions below