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

Discussion in 'ASP .Net' started by Stan, May 4, 2005.

  1. Stan

    Stan Guest

    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
    Stan, May 4, 2005
    #1
    1. Advertising

  2. Stan

    Brock Allen Guest

    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



    > 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, May 4, 2005
    #2
    1. Advertising

  3. Stan

    Stan Guest

    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" <> wrote in message
    news:...
    > 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
    >
    >
    >
    > > 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
    > >

    >
    >
    >
    Stan, May 5, 2005
    #3
  4. Stan

    Brock Allen Guest

    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



    > 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" <> wrote in message
    > news:...
    >
    >> 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
    >>> 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, May 5, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pablo Gutierrez
    Replies:
    0
    Views:
    336
    Pablo Gutierrez
    Oct 27, 2003
  2. Kivanç Karaca

    Best way of databinding to a daragrid

    Kivanç Karaca, Oct 11, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    306
    Alex Homer
    Oct 11, 2004
  3. jobs
    Replies:
    0
    Views:
    1,620
  4. Jimmy Stewpot
    Replies:
    0
    Views:
    265
    Jimmy Stewpot
    Mar 22, 2010
  5. Earl Teigrob
    Replies:
    1
    Views:
    402
    Shravan
    Mar 1, 2004
Loading...

Share This Page