Connecting Tech Pros Worldwide Forums | Help | Site Map

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

Stan
Guest
 
Posts: n/a
#1: Nov 19 '05
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



Brock Allen
Guest
 
Posts: n/a
#2: Nov 19 '05

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


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


[color=blue]
> 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
>[/color]



Stan
Guest
 
Posts: n/a
#3: Nov 19 '05

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


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..

"Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
news:642564632508223731954000@msnews.microsoft.com ...[color=blue]
> I've not yet tried it myself, but have you considered using an[/color]
XmlDataDocument?[color=blue]
> Perhaps you can use the ObjectDataSource, build your own class that does
> the Selects and Updates and then passback the XmlDataDocument as your[/color]
storage[color=blue]
> mechanism? If I had the time, it'd make for an interesting experiment.
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>[color=green]
> > 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
> >[/color]
>
>
>[/color]


Brock Allen
Guest
 
Posts: n/a
#4: Nov 19 '05

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


Oh yeah... If you're in v1.1 then there's no two-way databinding at all.
You'll have to code it all manually. Sorry.

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


[color=blue]
> 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..
>
> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
> news:642564632508223731954000@msnews.microsoft.com ...
>[color=green]
>> I've not yet tried it myself, but have you considered using an
>>[/color]
> XmlDataDocument?
>[color=green]
>> Perhaps you can use the ObjectDataSource, build your own class that
>> does the Selects and Updates and then passback the XmlDataDocument as
>> your
>>[/color]
> storage
>[color=green]
>> mechanism? If I had the time, it'd make for an interesting
>> experiment.
>>
>> -Brock
>> DevelopMentor
>> http://staff.develop.com/ballen[color=darkred]
>>> 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
>>>[/color][/color][/color]



Closed Thread