Hi everyone, I've been playing around with this code for a few hours now and I just can't figure out how to get the datagrid to refresh after I have sent a new item to the database.
I've seen many posts about using an arraycollection as a dataprovider for the datagrid, which is what I'm doing. Essentially, the httpsrv service gets the data from the server, and then the addtoarray function populates the arraycollection. when the data entered in the very basic form gets sent back, the function also calls the httpsrv again to re-populate the arraycollection. This is where things don't seem to work as they should. Perhaps my logic is wrong ;-) but I know that the httpsrv runs everytime because I added a quick alert pop-up to tell me it's running. any pointers will be appreciated! <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="httpsrv.send()"> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.rpc.events.ResultEvent; import mx.collections.ArrayCollection; private function checksuccess(evt:ResultEvent):void { labelsuccess.text = evt.result.success; labelsuccess2.text = ""; httpsrv.send(); myusers.refresh(); datagrid1.dataProvider=myusers; } [Bindable] private var myusers:ArrayCollection = new ArrayCollection(); private function addtoarray(evt:ResultEvent):void { myusers=(evt.result.stuff.people); mx.controls.Alert.show("inside Addarray right now"); labelsuccess2.text = labelsuccess.text + "addtoarray ran..."; /* <mx:DataGrid id="datagrid1" enabled="true" dataProvider="{httpsrv.lastResult.stuff.people}" editable="false" width="60%" height="85%" verticalCenter="-9" themeColor="#596DD3" textAlign="center" left="65" alpha="0.84" borderThickness="0" alternatingItemColors="[#F7F7F7, #FFFFFF]"> */ } ]]> </mx:Script> <mx:Panel width="90%" height="90%" layout="absolute" themeColor="#FF003C" verticalAlign="top" horizontalCenter="-16" verticalCenter="-5"> <mx:DataGrid id="datagrid1" enabled="true" dataProvider="{myusers}" editable="false" width="611" height="519" themeColor="#596DD3" textAlign="center" alpha="0.84" borderThickness="0" alternatingItemColors="[#F7F7F7, #FFFFFF]" x="0" y="0"> <mx:columns> <mx:DataGridColumn headerText="Database ID" dataField="id"/> <mx:DataGridColumn headerText="Client Name" dataField="name"/> <mx:DataGridColumn headerText="Client Email" dataField="email"/> </mx:columns> </mx:DataGrid> <mx:Form width="308" height="154" x="635" y="10"> <mx:FormHeading label="Add Item"/> <mx:FormItem label="Name" required="true"> <mx:TextInput id="input_name" editable="true" enabled="true"/> </mx:FormItem> <mx:FormItem label="E-Mail" required="true"> <mx:TextInput id="input_email" editable="true" enabled="true"/> </mx:FormItem> <mx:Button label="Button" labelPlacement="left" click="additem.send()"/> </mx:Form> <mx:Label width="256" id="labelsuccess" x="655" y="172" color="#2DB834"/> <mx:Label x="655" y="208" width="256" id="labelsuccess2"/> </mx:Panel> <mx:HTTPService id="httpsrv" url="http://cybweb01:82/dev/flex/allo.asp?task=data" useProxy="False" result="addtoarray(event)" showBusyCursor="true"> </mx:HTTPService> <mx:HTTPService id="additem" url="http://cybweb01:82/dev/flex/allo.asp?task=additem" method="POST" useProxy="False" result="checksuccess(event)" > <mx:request xmlns=""> <name>{input_name.text}</name> <email>{input_email.text}</email> </mx:request> </mx:HTTPService> </mx:Application>

