Groups | Blog | Home
all groups > dotnet windows forms databinding > november 2006 >

dotnet windows forms databinding : DataBinding to XML


Peter Morris [Droopy eyes software]
11/27/2006 6:54:58 PM
If I had some XML that was structured something like this...

<data>
<selectedValue id="1235"/>
<valueOptions>
<valueOption id="1234" name="Option 1"/>
<valueOption id="1235" name="Option 2"/>
<valueOption id="1236" name="Option 3"/>
</valueOptions>
</data>

Would it be possible to databind a WinForm like so....

Scenario A) A ComboBox with the items "Option 1", "Option 2", "Option 3"
which has the valueOption with id="1235" automatically selected and so that
changing the selected item updates the selectedValue.Id node?

Scenario B) A DataGrid listing the valueOptions as rows, where changing the
selected row index updates the selectedValue.Id node?


I've only ever databound objects before and not XML so your help would be
very gratefully received :-)

Thanks


Pete

Bart Mermuys
11/28/2006 2:53:18 PM
Hi,

"Peter Morris [Droopy eyes software]" <pete@droopyeyes.no.com.spam> wrote in
message news:OMUULWlEHHA.992@TK2MSFTNGP03.phx.gbl...
[quoted text, click to view]

There is no support for XML binding in NET2.0 (there is in WPF).

A couple of options:
- create a object model :
- that can be manually synchronised,
- that can be serialized/deserialized from/to your xml using
XmlSerializer or
- that wraps an XmlDocument
- a DataSet can be bound, can load XML and can save XML, but a DataSet XML
doesn't have the same structure, so you would need two xslt to transform.



HTH,
Greetings




[quoted text, click to view]

Peter Morris [Droopy eyes software]
11/28/2006 6:34:06 PM
Hi Bart

[quoted text, click to view]

Would WPF allow me to do two-way binding as I have described?

Thanks

Pete

Bart Mermuys
11/28/2006 9:03:55 PM
Hi,

"Peter Morris [Droopy eyes software]" <pete@droopyeyes.no.com.spam> wrote in
message news:O9$kLvxEHHA.3600@TK2MSFTNGP06.phx.gbl...
[quoted text, click to view]

I haven't looked at WPF all that much, but i do think it allows two-way
binding like you described.

HTH,
Greetings

[quoted text, click to view]

AddThis Social Bookmark Button