1 Reply Latest reply on Aug 22, 2009 8:49 PM by Madhav Subedi

    Flex DataGrid & .Net WebService (datatable)

    max.soft Level 1

      Hi all.

      I've created a simple Net WebMethod t retrive Customers and diplay on a flex datagrid.

      .Net side:


      <WebMethod()> _
      Public Function getCustomers() As XmlDocument
              Return getXmlFromDt(dao.getCustomers())
          End Function

              Private Function getXmlFromDt(ByVal dt As Data.DataTable) As System.Xml.XmlDocument
                  Dim sw As New IO.StringWriter
                  dt.WriteXml(sw)
                  Dim xd As New System.Xml.XmlDocument
                  xd.LoadXml(sw.ToString)
                  Return xd
              End Function

       

      Flex side:

       

              private function getCustomers_result(evt:ResultEvent):void {
                  dgCustomers.dataProvider = evt.result;
              }

       

              <mx:operation name="getCustomers"
                  resultFormat="e4x"
                  result="getCustomers_result(event);"
                  fault="ws_fault(event);">
              </mx:operation>

       

       

              <mx:DataGrid id="dgCustomers"
                  width="100%" height="100%">
                  <mx:columns>
                  <mx:DataGridColumn dataField="t_description" headerText="Customer" ></mx:DataGridColumn>
                  </mx:columns>
              </mx:DataGrid>

       

       

      It does not work.

      I've try with dgCustomers.dataProvider = evt.result.customers; also.

       

      how to?

      thank you.

      maxsoft