0 Replies Latest reply on May 8, 2009 10:29 AM by apmyhr

    Webservice result ArrayCollection's objects' attributes are unordered

    apmyhr

      I have an ASP.NET webservice which connects to a SQL Server DB.  The webservice has a function GetAllTableName() which just returns all of the items in a table as an ArrayList.  So in my Flex, I want to retrieve this array and bind the dataprovider for a DataGrid to it.  In action script, I have a WebService called service and I add an event listener to the method.

       

      service.GetAllTableName.addEventListener(ResultEvent.RESULT, MyResultHandler);

       

       

       

       

       

       

      public

       

       

      function MyResultHandler(event:ResultEvent):void

      { myArray = event.result as ArrayCollection; }

       

      So in my code I call service.GetAllTableName() and it retrieves the array and sets it as the dataprovider for my grid.  Now here is my problem.  The array's objects' attributes are in a different order than the database table.  It is alphabeticall.  So basically, instead of seeing [ID, Name, Description] I will see [Description, ID, Name] in the datagrid.  I know that I can manually create DataGrid columns with header texts and assigned data fields but this approach is not possible for me because I need to have all of this dynamic.  After debugging I see that the problem starts all the way back with event.result.  Can someone tell me if there is a way to fix this?  And incase you are wondering, I did check the actual generated wsdl response for the webservice call and the XML is structured so that the attributes are in the correct order, so this problem is isolated with Flex.