Dec 16, 2008, 5:29 AM
Problem with Update ASP "Formview" and Coolite "Gridpanel" in one aspx
Hi all, I've try to use coolite coding on a asp.net page which need access/update on one master table and a linked subtable, same structure as [order] and [orderdetail].
The page "OrderDetail.aspx" is intend to provide view/update function in one page, I use asp:formview to display data from SQL datasource, and use ext:GridPanel to show orderdetail grid.
When user create a new order, input order detail on grid and click submit button, I need to call FormViewOrder.InsertItem() to insert data in master table, and get the new id @id from reture value, then update all OrderId in subtable and save, via call client function #{GridPanelOrderList}.save() in listener.
I try to attach the AjaxEvents and Listener in one button, but they seems work seperately, so cause new OrderID can't be retrieve when gridpanel update. For temp solition, I split them in too button, just like below:
...
<asp:SqlDataSource ID="SqlDataSourceOrder" runat="server"
ConnectionString="xxxxxxxx"
selectcommand = "SELECT * FROM TB_Order"
......
>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSourceOrderDetail" runat="server"
ConnectionString="xxxxxxxx"
selectcommand = "SELECT * FROM TB_OrderDetail where OrderID=xxx"
OnInserted="SqlDataSourceOrder_Inserted"
......
>
</asp:SqlDataSource>
<ext:Store ID="StoreOrderDetail" runat="server" DataSourceID="SqlDataSourceOrderDetail"
OnBeforeRecordInserted ="StoreOrderDetail_BeforeRecordInserted"
>
<Reader>
<ext:JsonReader ReaderID="OrderDetailID">
<Fields>
<ext:RecordField Name="OrderID" />
......
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
...
<asp:FormView ID="FormViewOrder" runat="server" DataKeyNames="OrderID" DataSourceID="SqlDataSourceOrder" DefaultMode="Insert">
<ItemTemplate>
......
</ItemTemplate>
<InsertItemTemplate>
</InsertItemTemplate>
</asp:FormView>
<ext:GridPanel ID="GridPanelOrderDetail" runat="server" StoreID="StoreOrderDetail"
...
>
...
<ext:Button ID="btnNext1" runat="server" Text="Save Order" Icon="Accept">
<AjaxEvents>
<Click OnEvent="SaveOrder">
</AjaxEvents>
</ext:Button>
<ext:Button ID="btnNext2" runat="server" Text="Save Order Detail" Icon="Accept">
<Listeners>
<Click Handler="#{GridPanelOrderDetail}.save();" />
</Listeners>
</ext:Button>
My question are: 1. how can I combine they together ?
2. I fell it's not a good solution to use formview and gridpanel together, because they are using different programing method, is there any solution in coolite to replace forview/detail view work with datasource and store?
Pls kindly help, thanks a lot!