Typed Dataset heirarchy problem

  • Thread starter Thread starter Chuck Bowling
  • Start date Start date
C

Chuck Bowling

I have a typed dataset with a root element - InstrumentSet with a collection
of Instruments. Each instrument has a Comment, a Name, a SourceCode block,
and a collection of Parameters. Like so:

<InstrumentSet>
<Instrument>
<Comment>xxx</Comment>
<Name>myName</Name>
<SourceCode>myCode</SourceCode>
<Parameter>
<P1>aaa</P1>
<P2>bbb</P2>
</Parameter>
</Instrument>
</InstrumentSet>

I'm using databindings to hold the instrument name, comment and sourcecode
in text boxes. I want to use a datagrid to hold a list of Parameters for
each Instrument but I can't quite figure out how to drill down to the
Parameter table for each Instrument. I tried variations on the following:

txtName.DataBindings.Add(new Binding("Text", instrumentSet,
"Instrument.Name"));

txtComment.DataBindings.Add(new Binding("Text", instrumentSet,
"Instrument.Comment"));

txtSourceCode.DataBindings.Add(new Binding("Text", instrumentSet,
"Instrument.SourceCode"));

dgParameters.DataSource = instrumentSet;

this.bmInstruments = this.BindingContext[instrumentSet, "Instrument"];



I can't figure out what the correct dgParameters.DataSource statement should
be. Can someone help?
 
I have a typed dataset with a root element - InstrumentSet with a
collection
of Instruments. Each instrument has a Comment, a Name, a SourceCode block,

and a collection of Parameters. Like so:

<InstrumentSet>
<Instrument>
<Comment>xxx</Comment>
<Name>myName</Name>
<SourceCode>myCode</SourceCode>
<Parameter>
<P1>aaa</P1>
<P2>bbb</P2>
</Parameter>
</Instrument>
</InstrumentSet>

Yeah, I ran into the same wall. You're better off using XPath.
 
Thanks Bob. I was thinking the same thing but had already comitted to what I
have now. Lots of code is going to need changing. ;)
 
Back
Top