Dear,
I'm using the Telerik Grid for one of my webprojects.
The grid show data for a purchase order. For a line 2 subgrids can optionally contain data.
When loading the grid for the first time, it works fine.
When I edit a row, i do this with a server postback that shows a modal popup.
If the user saves changes for a line, another server postback happens and the grid is reloaded.
With this reload, only data in the main grid is shown. The subgrids don't show any data.
The need_datasource event is not even fired this time. However the code is exactly the same, so I don't understand what can be wrong.
Can someone help me with this weird issue?
Many thanks in advance!
Best regards, Koen
UI:
Code behind:
I'm using the Telerik Grid for one of my webprojects.
The grid show data for a purchase order. For a line 2 subgrids can optionally contain data.
When loading the grid for the first time, it works fine.
When I edit a row, i do this with a server postback that shows a modal popup.
If the user saves changes for a line, another server postback happens and the grid is reloaded.
With this reload, only data in the main grid is shown. The subgrids don't show any data.
The need_datasource event is not even fired this time. However the code is exactly the same, so I don't understand what can be wrong.
Can someone help me with this weird issue?
Many thanks in advance!
Best regards, Koen
UI:
<telerik:RadGrid ID="RadGridOrderLines" AutoGenerateColumns="false" AllowPaging="false" runat="server"> <MasterTableView HierarchyDefaultExpanded="true" DataKeyNames="PurchaseOrderDetailID"> <Columns> <telerik:GridButtonColumn ImageUrl="~/Images/edit_16x16.gif" CommandName="editline" ButtonType="ImageButton" ></telerik:GridButtonColumn> <telerik:GridBoundColumn HeaderText="ITE" DataField="ArticleITECode" SortExpression="ArticleITECode"></telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText='<%$ Resources:CommonTerms, Article %>' DataField="ArticleName" SortExpression="ArticleName"></telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText='<%$ Resources:CommonTerms, Status %>' DataField="PurchaseOrderDetailStatusDescription" SortExpression="PurchaseOrderDetailStatusDescription"></telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText='<%$ Resources:CommonTerms, Price %>' DataField="ArticleUnitPrice" DataFormatString="{0:F2}" SortExpression="ArticleUnitPrice"></telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText='<%$ Resources:CommonTerms, Quantity %>' DataField="PurchaseOrderDetailQuantity" DataFormatString="{0:F0}" SortExpression="PurchaseOrderDetailQuantity"></telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText='<%$ Resources:CommonTerms, Remark %>' DataField="PurchaseOrderDetailRemarks" SortExpression="PurchaseOrderDetailRemarks"></telerik:GridBoundColumn> </Columns> <NestedViewTemplate> <asp:Panel CssClass="pad5" runat="server" ID="panelDeliveries"> <asp:Label runat="server" ID="lblDeliveries" Text='<%$ Resources:CommonTerms, Deliveries %>'></asp:Label> <asp:Label runat="server" ID="lblDeliveriesCount"></asp:Label><br /> <telerik:RadGrid ID="RadGridDelivery" AutoGenerateColumns="false" AllowPaging="false" runat="server"> <MasterTableView> <Columns> <telerik:GridBoundColumn HeaderText="ITE" DataField="ArticleITECode" SortExpression="ArticleITECode"></telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText='<%$ Resources:CommonTerms, Article %>' DataField="ArticleName" SortExpression="ArticleName"></telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText='<%$ Resources:CommonTerms, Status %>' DataField="PurchaseDeliveryStatus" SortExpression="PurchaseDeliveryStatus"></telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText='<%$ Resources:CommonTerms, Price %>' DataField="ArticleUnitPrice" DataFormatString="{0:F2}" SortExpression="ArticleUnitPrice"></telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText='<%$ Resources:CommonTerms, Quantity %>' DataField="PurchaseDeliveryQuantity" DataFormatString="{0:F0}" SortExpression="PurchaseDeliveryQuantity"></telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText='<%$ Resources:CommonTerms, Remark %>' DataField="PurchaseDeliveryRemarks" SortExpression="PurchaseDeliveryRemarks"></telerik:GridBoundColumn> </Columns> </MasterTableView> </telerik:RadGrid> </asp:Panel> <asp:Panel runat="server" ID="panelAssets" CssClass="pad5"> <asp:Label runat="server" ID="lblAssets" Text='<%$ Resources:CommonTerms, Assets %>'></asp:Label> <asp:Label runat="server" ID="lblAssetsCount"></asp:Label><br /> <telerik:RadGrid ID="RadGridAssets" AutoGenerateColumns="false" AllowPaging="false" runat="server"> <MasterTableView HierarchyDefaultExpanded="true" DataKeyNames="PurchaseDeliveryAssetID"> <Columns> <telerik:GridBoundColumn HeaderText="Asset" DataField="AssetType" SortExpression="AssetType"></telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText='<%$ Resources:CommonTerms, Quantity %>' DataField="PurchaseDeliveryAssetQuantity" DataFormatString="{0:F0}" SortExpression="PurchaseOrderDetailQuantity"></telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText='<%$ Resources:CommonTerms, Price %>' DataField="AssetUnitPrice" DataFormatString="{0:F2}" SortExpression="ArticleUnitPrice"></telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText='<%$ Resources:CommonTerms, Currency %>' DataField="Currency" SortExpression="ArticleName"></telerik:GridBoundColumn> </Columns> </MasterTableView> </telerik:RadGrid> </asp:Panel> </NestedViewTemplate> </MasterTableView></telerik:RadGrid>Code behind:
Private Sub FillPage(ByVal id As Int32) Dim order = Univeg.BL.PurchaseOrder.GetByID(id, SessionVars.CuCo) If order Is Nothing Then lblErrorPurchaseOrderNotFound.Visible = True Return End If Me.PurchaseOrderID = id lblNumber2.Text = order.PurchaseOrderNumber lblSupplierName.Text = order.SupplierCode & " - " & order.SupplierName lblSupplierCity.Text = order.SupplierZipCode & " - " & order.SupplierCity lblWarehouse.Text = order.WarehouseCode & " - " & order.WarehouseName lblOrderStatus.Text = order.PurchaseOrderStatusDescription lblDepartment.Text = order.DepartmentName Dim orderlines = Univeg.BL.PurchaseOrderDetail.GetLinesForOrder(id, SessionVars.CuCo) ' get delivery lines DeliveryLines = Univeg.BL.PurchaseDelivery.GetPurchaseLinesForOrder(id, SessionVars.CuCo) ' get delivery assets DeliveryAssetLines = Univeg.BL.PurchaseDeliveryAsset.GetListForOrder(id) RadGridOrderLines.DataSource = orderlines RadGridOrderLines.DataBind() Dim assets = Univeg.BL.PurchaseOrderAsset.GetListForOrder(id) lblAssetsCount.Text = assets.Count.ToString() RadGridAssets.DataSource = assets RadGridAssets.DataBind()End SubProtected Sub RadGridDelivery_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Dim RadGridDelivery As Telerik.Web.UI.RadGrid = sender Dim nestedItem As GridNestedViewItem = DirectCast(TryCast(sender, RadGrid).NamingContainer, GridNestedViewItem) Dim PurchaseOrderDetailID As Int32 = nestedItem.ParentItem.GetDataKeyValue("PurchaseOrderDetailID") If DeliveryLines Is Nothing Then DeliveryLines = Univeg.BL.PurchaseDelivery.GetPurchaseLinesForOrder(Me.PurchaseOrderID, SessionVars.CuCo) End If If Not DeliveryLines Is Nothing Then Dim delivery = (From dl In DeliveryLines _ Where dl.PurchaseOrderDetailID = PurchaseOrderDetailID _ Order By dl.PurchaseDeliveryTHT _ Select dl).ToList() If delivery.Count > 0 Then RadGridDelivery.DataSource = delivery Dim lblDeliveriesCount As Label = nestedItem.FindControl("lblDeliveriesCount") If Not lblDeliveriesCount Is Nothing Then lblDeliveriesCount.Text = delivery.Count.ToString() End If Else RadGridDelivery.Visible = False Dim panelDeliveries As Panel = nestedItem.FindControl("panelDeliveries") If Not panelDeliveries Is Nothing Then panelDeliveries.Visible = False End If End If End IfEnd SubProtected Sub RadGridAssets_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Dim RadGridAssets As Telerik.Web.UI.RadGrid = sender Dim nestedItem As GridNestedViewItem = DirectCast(TryCast(sender, RadGrid).NamingContainer, GridNestedViewItem) Dim PurchaseOrderDetailID As Int32 = nestedItem.ParentItem.GetDataKeyValue("PurchaseOrderDetailID") If Not DeliveryAssetLines Is Nothing Then Dim assets = (From da In DeliveryAssetLines _ Where da.PurchaseOrderDetailID = PurchaseOrderDetailID _ Order By da.AssetType _ Select da).ToList() If assets.Count > 0 Then RadGridAssets.DataSource = assets Dim lblAssetsCount As Label = nestedItem.FindControl("lblAssetsCount") If Not lblAssetsCount Is Nothing Then lblAssetsCount.Text = assets.Count.ToString() End If Else Dim panelAssets As Panel = nestedItem.FindControl("panelAssets") If Not panelAssets Is Nothing Then panelAssets.Visible = False End If End If End IfEnd SubProtected Sub RadGridOrderLines_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RadGridOrderLines.ItemCreated If TypeOf e.Item Is GridNestedViewItem Then Dim RadGridDelivery As RadGrid = e.Item.FindControl("RadGridDelivery") Dim RadGridAssets As RadGrid = e.Item.FindControl("RadGridAssets") If Not RadGridDelivery Is Nothing Then AddHandler RadGridDelivery.NeedDataSource, AddressOf RadGridDelivery_NeedDataSource End If If Not RadGridAssets Is Nothing Then AddHandler RadGridAssets.NeedDataSource, AddressOf RadGridAssets_NeedDataSource End If End IfEnd Sub