1 Reply Latest reply on May 24, 2010 10:42 PM by dasun1981

    Help around passing ArrayCollection to an ASP.net Page

    dasun1981

      I have a datagrid filled using an array collection. However I need to send these data in the array collection in to an asp.net page, so I can write them in to the database table. I saw that passing this connection as xml using the  contentType="application/xml" property in HTTPService is the ideal way. However I can see that when I send the requst to the asp.net page, the HTTPService is passing the data as a XML string in the Network monitor. But I dont know how I can access this data in the ASP.net page.

       

      Help here would be greatly appriciated. I tried to get this by using the request.params and request.form, but non didnt work. Also I'm passing data using the POST method. The code is as follows,

       

      <mx:HTTPService
                  id="Service_AddClaim"
                  url="http://localhost/wautomation/Claim_Add.aspx"
                  contentType="application/xml"
                  method="POST"
                  result="Service_AddClaim_resultHandler(event)"
                  useProxy="false" />


      protected function button2_clickHandler(event:MouseEvent):void
      {              
           Service_AddClaim.send(claimList.source);
      }

       

      Also any best practices around updating multiple data collections would be greatly appriciated as well.

        • 1. Re: Help around passing ArrayCollection to an ASP.net Page
          dasun1981 Level 1

          Finally found a way to do this using the xml context method in the httpservice and using stream reader in the asp.net side.

           

          Here is my code, hope it will be useful for someone,

           

          XmlDocument xmlDoc = new XmlDocument();
          Page.Response.ContentType = "text/xml";
          StreamReader reader = new StreamReader(Page.Request.InputStream);

           

          string XmlData = reader.ReadToEnd();
          XmlData = "<items>" + XmlData + "</items>";

           

          xmlDoc.LoadXml(XmlData);

           

          I have added the <items> as the root since the httpservice parse everything in a collection which produce errors when loading to XmlDocument.