adding a single variable to a dataset
i'm trying write basic c# forms application reads xml config file, displays data in datagridview user edit, , saves changes xml config file. works fine except user wants add version number or datatimestamp file everytime it's written out. have is: xml file format <config_data> <version>1.1</version> <record> <name>jen</name> <num>5</num> </record> <record> <name>joe</name> <num>6</num> </record>......
read in xml file , set dataset: xmlreader xmlfile; //create xml reader , read in file avds=new dataset; avds.readxml(xmlfile);
i set databinding bind datagridview dataset: datagridview.datasource=ds; datgridview.datamember="record";
and when user hits save write out: xmlwriter xmlfile; ds.writexml(xmlfile);
but writes out data in <record> fields i've shown user editing. since i'm writing dataset directly xml file i'm not sure how can stick version number in xml file without having reopen file using xml writer , manually insert version number.
hi jmh1819,
welcome msdn forum support.
feel can refer msdn magzine for getting q&a conversations. talking question.
a simplest possible solution load xml dataset , bind that. solution use xml serialization create object graph xml , bind that. bind raw xml, need create wrapper classes implement itypedlist, ibindinglist, , icustomtypedescriptor.
meanwhile, here detailed implementations can refer to:
building xml applications .net framework 2.0
can use xmltextwriter compose xml structure used to be bound datagridview control according datasource property.
sincerely,
jason wang
jason wang [msft]
msdn community support | feedback us
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment