What is the best way to make dual-way xml databinding?

S

Stan

I am looking for the best solution for this scenario:

ASP.NET needs display an editable form with 20 textboxes. Data source is
xml. Xml must be updated. if user clicks Update button on the form.

Scenario 1 - brute force

Load xml into XmlDocument,
txtName.Text = doc.SelectSingleNode ('\\bla\@bla").Value

private void OnNameChanged(object sender, System.EventArgs e)
{
doc.SelectSingleNode ("\\bla\@bla").Value = txtName.Text
}

Scenario 2 - databinind
Load DataSet from xml, hook up text box with dataset in txtName_Databinding
event I am not sure if it will work both ways.

Scenario 3 - Xml data island
I worked well in the past, not sure if it is still the best way to go..

I appreciate any opinions on that subject

-Stan
 
B

Brock Allen

I've not yet tried it myself, but have you considered using an XmlDataDocument?
Perhaps you can use the ObjectDataSource, build your own class that does
the Selects and Updates and then passback the XmlDataDocument as your storage
mechanism? If I had the time, it'd make for an interesting experiment.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
S

Stan

I cannot use XmlDataDocument because xml comes out of sql server directly
(FOR XML EXPLICIT) and there is no dataset (doc = new XmlDataDocument (ds))

ObjectDataSource is from NET 2.0 and I forgot to mention that this is in
1.1. Yes a lot of things will be simpler in 2.0, especially xml and object
databinding

One of the problem is that even with xml databinding I can bind control on
the server, but after postback this binding is lost, similar with DataGrid.
I guess there is no magic way to do that..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top