Flex DataGrid Sample

Step 1:
Create a Web Service as i mentioned in my ASP.NET WebService tab of my blog.
(home page of my site)

File--->>> New--->>> Flex Project--->>>
Step 2:
Project Name(eg:- sampleWS)
Step 3:
Application Type:(choose Web)
Step 4:
Flex SDK Version
Use specific SDK:(choose flex 3.5)
Step5:
Server technology
Application server type(choose ASP.NET)
--->>>next--->>>finish
Step6:

and copy paste the following flex code in sampleWS.mxml file.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()" layout="absolute" minWidth="955" minHeight="600">
    <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.rpc.AbstractService;
            import mx.rpc.AsyncToken;
            import mx.rpc.IResponder;
            import mx.rpc.events.ResultEvent;
            import mx.rpc.soap.WebService;
            private var resultDoctorList:ArrayCollection;
            private var objService:AbstractService=null;
            private var resToken:AsyncToken=null;
            private var ws:WebService=null;
            protected function init():void
            {               
                ws = new WebService();
                ws.rootURL = "http://localhost:12315/sampleWS/Service.asmx?WSDL";
                ws.wsdl = "http://localhost:12315/sampleWS/Service.asmx?WSDL";                        
                ws.loadWSDL();
                objService=ws;
                resToken=AsyncToken(objService.getDoctorDetails());
                objService.addEventListener(ResultEvent.RESULT,handleGetDoctorDetails);
            }
            private function handleGetDoctorDetails(event:ResultEvent):void{               
                    resultDoctorList = event.result as ArrayCollection;
                    userDoctorDataGrid.dataProvider=resultDoctorList;
            }
        ]]>
    </mx:Script>
    <mx:DataGrid id="userDoctorDataGrid" x="175" y="90">
        <mx:columns>
            <mx:DataGridColumn headerText="Doctor ID" dataField="DoctorID"/>
            <mx:DataGridColumn headerText="Doctor Name" dataField="Doctor_Name"/>
            <mx:DataGridColumn headerText="Specialist" dataField="Specialist"/>
            <mx:DataGridColumn headerText="Gender" dataField="Gender"/>
            <mx:DataGridColumn headerText="Phone" dataField="Phone"/>
        </mx:columns>
    </mx:DataGrid>
</mx:Application>



[Note: For rootURL and wsdl use your own webservice URL(along with "?WSDL").]

2 comments:

  1. hai vijay,
    add more asp.net articles and sample codes on our blog

    regard
    B.Natarjan

    ReplyDelete
  2. i want a flex grid to insert a value using ASP.net

    ReplyDelete