Not able to update\delete child Grid

2 posts, 0 answers
  1. Devarshi
    Devarshi avatar
    2 posts
    Member since:
    Jul 2015

    Posted 08 Jul 2015 Link to this post

    I have hierarchy grid. I am able to edit\delete parent grid but not child grid (second grid). I using the same code behind and subs for both the grids. When I click on edit button for row of second grid, it enables edit mode but when I click on update button, it is not changing values on UI nor in database tables. And build is correct, it is not giving any error. Following is my code. If anybody can please help me!

     

    <%@ Page Language="vb" AutoEventWireup="false" Inherits="WebApplication1.invoice_details" CodeBehind="invoice_details.aspx.vb" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
        <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>

        <div>
            <telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" ShowStatusBar="true"
                AutoGenerateColumns="False" AllowSorting="True" AllowMultiRowSelection="False"
                AllowAutomaticDeletes="True" 
                AllowAutomaticUpdates="True" OnItemUpdated="RadGrid1_ItemUpdated" OnItemDeleted="RadGrid1_ItemDeleted">
                <PagerStyle Mode="NumericPages"></PagerStyle>
                <MasterTableView DataSourceID="SqlDataSource1" EditMode = "InPlace" DataKeyNames="case_id" AllowMultiColumnSorting="True"
                    Width="100%" CommandItemDisplay="Top" Name="Cases">
                    <DetailTables>
                        <telerik:GridTableView EditMode = "InPlace" DataKeyNames="item_id" DataSourceID="SqlDataSource2" Width="100%"
                            runat="server" CommandItemDisplay="Top" Name="Items">
                            <ParentTableRelation>
                                <telerik:GridRelationFields DetailKeyField="case_id" MasterKeyField="case_id"></telerik:GridRelationFields>
                            </ParentTableRelation>                        
                            <Columns>
                                <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn2">
                                    <HeaderStyle Width="20px"></HeaderStyle>
                                    <ItemStyle CssClass="MyImageButton"></ItemStyle>
                                </telerik:GridEditCommandColumn>
                                <telerik:GridBoundColumn SortExpression="grp_id" HeaderText="Group" HeaderButtonType="TextButton"
                                    DataField="grp_id" UniqueName="grp_id" ReadOnly = "True">
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn SortExpression="item_id" HeaderText="Item ID" HeaderButtonType="TextButton"
                                    DataField="item_id" UniqueName="item_id" ReadOnly = "True" Visible = "False">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn SortExpression="inv_item_desc" HeaderText="Item Description" HeaderButtonType="TextButton"
                                    DataField="inv_item_desc" UniqueName="inv_item_desc">
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn SortExpression="inv_item_rate" HeaderText="Rate" HeaderButtonType="TextButton"
                                    DataField="inv_item_rate" UniqueName="inv_item_rate">
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn SortExpression="inv_item_qty" HeaderText="Quantity" HeaderButtonType="TextButton"
                                    DataField="inv_item_qty" UniqueName="inv_item_qty">
                                </telerik:GridBoundColumn>   
                                <telerik:GridBoundColumn SortExpression="total" HeaderText="Total" HeaderButtonType="TextButton"
                                    DataField="total" UniqueName="total" ReadOnly = "True">
                                </telerik:GridBoundColumn>                         
                                <telerik:GridButtonColumn ConfirmText="Delete these details record?" ButtonType="ImageButton"
                                    CommandName="Delete" Text="Delete" UniqueName="DeleteColumn2">
                                    <HeaderStyle Width="20px"></HeaderStyle>
                                    <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton"></ItemStyle>
                                </telerik:GridButtonColumn>
                            </Columns>
                        </telerik:GridTableView>
                    </DetailTables>
                    <Columns>
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                            <HeaderStyle Width="20px"></HeaderStyle>
                            <ItemStyle CssClass="MyImageButton"></ItemStyle>
                        </telerik:GridEditCommandColumn>
                        <telerik:GridBoundColumn SortExpression="case_id" HeaderText="Case ID" HeaderButtonType="TextButton"
                            DataField="case_id" UniqueName="case_id" MaxLength="5" ReadOnly = "True">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn SortExpression="case_file_nbr" HeaderText="Case File Number" HeaderButtonType="TextButton"
                            DataField="case_file_nbr" UniqueName="case_file_nbr">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn SortExpression="case_desc" HeaderText="Case Description" HeaderButtonType="TextButton"
                            DataField="case_desc" UniqueName="case_desc">
                        </telerik:GridBoundColumn>
                        <telerik:GridButtonColumn ConfirmText="Delete this case?" ButtonType="ImageButton"
                            CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                            <HeaderStyle Width="20px"></HeaderStyle>
                            <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton"></ItemStyle>
                        </telerik:GridButtonColumn>
                    </Columns>
                    <SortExpressions>
                        <telerik:GridSortExpression FieldName="case_desc"></telerik:GridSortExpression>
                    </SortExpressions>
                </MasterTableView>
            </telerik:RadGrid>
        </div>

        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="Server=172.18.1.11;Database=ent64ast;user id=entqalogin;password=en7qal8g1n5"
            DeleteCommand="DELETE FROM tbl_inv_case WHERE org_id= 'Oindem' and inv_no=31 and case_id = @case_id"
            SelectCommand="SELECT case_id,case_file_nbr,case_desc from tbl_inv_case where org_id='Oindem' and inv_no=31"
            UpdateCommand="UPDATE tbl_inv_case SET case_file_nbr = @case_file_nbr, case_desc = @case_desc WHERE org_id= 'Oindem' and inv_no=31 and case_id = @case_id">
            <DeleteParameters>
                <asp:Parameter Name="case_id" Type="String"></asp:Parameter>
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="org_id" Type="String"></asp:Parameter>
                <asp:Parameter Name="inv_no" Type="String"></asp:Parameter>
                <asp:Parameter Name="case_id" Type="String"></asp:Parameter>
                <asp:Parameter Name="case_file_nbr" Type="String"></asp:Parameter>
                <asp:Parameter Name="case_desc" Type="String"></asp:Parameter>
                <asp:Parameter Name="case_amnt" Type="String"></asp:Parameter>
                    <asp:SessionParameter Name="login_id" Type="string"  SessionField="loginid" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="case_id" Type="String"></asp:Parameter>
                <asp:Parameter Name="case_file_nbr" Type="String"></asp:Parameter>
                <asp:Parameter Name="case_desc" Type="String"></asp:Parameter>
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server"
            ConnectionString="Server=172.18.1.11;Database=ent64ast;user id=entqalogin;password=en7qal8g1n5"
            DeleteCommand="DELETE FROM tbl_inv_case_items WHERE org_id= 'Oindem' and inv_no=31 and case_id = @case_id and item_id = @item_id"
            SelectCommand="SELECT grp_id,case_id,item_id,inv_item_desc,inv_item_rate,inv_item_qty, cast(inv_item_rate*inv_item_qty as decimal(18,2)) 'total' FROM tbl_inv_case_items WHERE org_id='Oindem' AND inv_no=31 AND case_id = @case_id ORDER BY grp_id,case_id, inv_item_seqn"
            UpdateCommand="UPDATE tbl_inv_case_items SET inv_item_desc = @inv_item_desc, inv_item_rate = @inv_item_rate, inv_item_qty = @inv_item_qty WHERE org_id= 'Oindem' AND inv_no=31 AND case_id = @case_id AND item_id = @item_id">
            <DeleteParameters>
                <asp:Parameter Name="item_id" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="case_id" Type="String"></asp:Parameter>
            </DeleteParameters>
            <SelectParameters>
            <asp:Parameter Name="case_id" Type="String"></asp:Parameter>
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="inv_item_desc" Type="String"></asp:Parameter>
                <asp:Parameter Name="inv_item_rate" Type="Double"></asp:Parameter>
                <asp:Parameter Name="inv_item_qty" Type="Double"></asp:Parameter>
                <asp:Parameter Name="item_id" Type="String"></asp:Parameter>
                <asp:Parameter Name="case_id" Type="String"></asp:Parameter>
            </UpdateParameters>
        </asp:SqlDataSource>    
        </form>
    </body>
    </html>

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2342 posts

    Posted 13 Jul 2015 Link to this post

    Hello,

    I have examined the code and the setup seems correct. However, there could be some other cause for the behavior.

    Please disable AJAX by setting the EnableAJAX property of RadAjaxManager to false and check if there is an error thrown when updating the data.

    Regards,
    Viktor Tachev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top