How to bind xmldocument from web services into datalist help

Last post 05-20-2008 9:40 AM by xiuxian. 5 replies.

Sort Posts:

  • How to bind xmldocument from web services into datalist help

    05-16-2008, 2:19 PM
    • Loading...
    • xiuxian
    • Joined on 07-27-2004, 5:30 AM
    • Posts 194

    Hi,

    I have a method on a web services with return xmldocument. but now on the aspx file, I know how to call this method, but how to bind this xmldocument into datalist? please help.

    Thanks.

     

     

  • Re: How to bind xmldocument from web services into datalist help

    05-17-2008, 3:45 AM
    • Loading...
    • whatispunk
    • Joined on 03-06-2007, 5:21 PM
    • Winnipeg
    • Posts 623

    XmlNode xml = callToWebservice();  // An XmlDocument returned from a WebMethod is marshalled as an XmlNode

    XmlDataSource xds = new XmlDataSource();
    xds.EnableCaching = false; // Caching is enabled by default. You must do this or your databound control will NEVER update
    xds.LoadXml(xml.InnerXml);

    theDataList.DataSource = xds;
    theDataList.DataBind();

    You can use xpath expressions for binding in your DataList templates. i.e. <%# XPath('//Item[@Attribute="whatever"]') %>
     

    Don't forget to click "Mark as Answer" if someone answers your question. Feel free to mark more than one answer, if you feel so inclined.
  • Re: How to bind xmldocument from web services into datalist help

    05-19-2008, 2:36 AM

    Hi xiuxian,

    You can see this useful link:

    http://msdn2.microsoft.com/zh-cn/library/73yw7ttd(VS.80).aspx

     

    Sincerely,
    Samu Zhang
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
  • Re: How to bind xmldocument from web services into datalist help

    05-19-2008, 9:40 AM
    • Loading...
    • xiuxian
    • Joined on 07-27-2004, 5:30 AM
    • Posts 194

    thanks. but, when I run the code. I got an error. please help.

     Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS1061: 'System.Web.UI.WebControls.XmlDataSource' does not contain a definition for 'LoadXml' and no extension method 'LoadXml' accepting a first argument of type 'System.Web.UI.WebControls.XmlDataSource' could be found (are you missing a using directive or an assembly reference?)

    Source Error:

    Line 32:          XmlDataSource xds = new XmlDataSource();
    Line 33:          xds.EnableCaching = false; // Caching is enabled by default. You must do this or your databound control will NEVER update
    Line 34:          xds.LoadXml(xml.InnerXml);
    Line 35:  
    Line 36: 

      here is my code: 


             localhost.getempinfo myempinfo = new localhost.getempinfo();    
             XmlNode xml = myempinfo.GetEmpDetailsXML();  // call method, return a xmlcodment which has firstname,lastname,email..

             XmlDataSource xds = new XmlDataSource();
             xds.EnableCaching = false; 

             xds.LoadXml(xml.InnerXml);
     

             rpMyRepeater.DataSource = xds;
             rpMyRepeater.DataBind(); 

     

  • Re: How to bind xmldocument from web services into datalist help

    05-19-2008, 11:22 PM
    Answer
    • Loading...
    • whatispunk
    • Joined on 03-06-2007, 5:21 PM
    • Winnipeg
    • Posts 623

     My bad.

    xds.Data = xml.InnerXml;

    Don't forget to click "Mark as Answer" if someone answers your question. Feel free to mark more than one answer, if you feel so inclined.
  • Re: How to bind xmldocument from web services into datalist help

    05-20-2008, 9:40 AM
    • Loading...
    • xiuxian
    • Joined on 07-27-2004, 5:30 AM
    • Posts 194

     

    Thanks. problem solved.
Page 1 of 1 (6 items)