Child grid in nested grid disappears when clicking edit button

6 posts, 0 answers
  1. ToltingColtAcres
    ToltingColtAcres avatar
    83 posts
    Member since:
    Nov 2010

    Posted 16 Dec 2013 Link to this post

    have a radgrid with a nested radgrid containing child records. Everything works ok for purposes of data retrieval. Nested radgrid has in-place editing for data. When I click the edit button, the child grid disappears, leaving just the master grid in edit mode. Example shown in pic1 attached. When I click the pencil on any of the child records, that whole section disappears and the "update/cancel" buttons move up immediately under the wac pricing.





    Code attached. Would like to know what I'm doing wrong, or, what I need to adjust to make it work. Thanks.



    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Products.aspx.cs" Inherits="CIPAS.Web.Admin.Products" MasterPageFile="../Startup/CIPAS.Master" %>
     
    <asp:Content runat="server" ContentPlaceHolderID="body">
        <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid_Products">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid_Products" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="RadGrid_WAC" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="RadGrid_AMP" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="RadGrid_BAS" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="RadGrid_CMS" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManagerProxy>  
        <asp:SqlDataSource ID="SqlDataSource_Form" runat="server" ConnectionString="<%$ ConnectionStrings:CIPAS.Web.Properties.Settings.CIPASCS %>" SelectCommand="SELECT * FROM sysComboBoxValues WHERE ComboBox = 'FM' OR ComboBox = '' ORDER BY Code ASC" />
        <asp:SqlDataSource ID="SqlDataSource_UOM"  runat="server" ConnectionString="<%$ ConnectionStrings:CIPAS.Web.Properties.Settings.CIPASCS %>" SelectCommand="SELECT * FROM sysComboBoxValues WHERE ComboBox = 'UM' OR ComboBox = '' ORDER BY Code ASC" />
        <asp:SqlDataSource ID="SqlDataSource_Products" runat="server"
                           ConnectionString="<%$ ConnectionStrings:CIPAS.Web.Properties.Settings.CIPASCS %>"
                           InsertCommand="INSERT INTO ProductAdministration_Products (RowGUID_Key, NDC, NDC2, Name, Form_GUID, UOM_GUID, UnitsPerPackage, ApprovalDate, IntroductionDate, TerminationDate, ProductCode, Finance_ProductCode, UpdatedOn, UpdatedBy, sysRevision) VALUES (NEWID(), @NDC, @NDC2, @Name, @Form_GUID, @UOM_GUID, @UnitsPerPackage, @ApprovalDate, @IntroductionDate, @TerminationDate, @ProductCode, @Finance_ProductCode, GETDATE(), dbo.udf_GetEmployeeGUID(SUSER_NAME()), 0)"
                           SelectCommand="SELECT * FROM ProductAdministration_Products"
                           UpdateCommand="UPDATE ProductAdministration_Products SET NDC = @NDC, NDC2 = @NDC2, Name = @Name, Form_GUID = @Form_GUID, UOM_GUID = @UOM_GUID, UnitsPerPackage = @UnitsPerPackage, ApprovalDate = @ApprovalDate, IntroductionDate = @IntroductionDate, TerminationDate = @TerminationDate, ProductCode = @ProductCode, Finance_ProductCode = @Finance_ProductCode, UpdatedOn = GETDATE(), UpdatedBy = dbo.udf_GetEmployeeGUID(SUSER_NAME()), sysRevision = sysRevision + 1 WHERE RowGUID_Key = @RowGUID_Key" >
            <InsertParameters>
                <asp:Parameter Name="NDC" />
                <asp:Parameter Name="NDC2" />
                <asp:Parameter Name="Name" />
                <asp:Parameter Name="Form_GUID" />
                <asp:Parameter Name="UOM_GUID" />
                <asp:Parameter Name="UnitsPerPackage" />
                <asp:Parameter Name="ApprovalDate" />
                <asp:Parameter Name="IntroductionDate" />
                <asp:Parameter Name="TerminationDate" />
                <asp:Parameter Name="ProductCode" />
                <asp:Parameter Name="Finance_ProductCode" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="NDC" />
                <asp:Parameter Name="NDC2" />
                <asp:Parameter Name="Name" />
                <asp:Parameter Name="Form_GUID" />
                <asp:Parameter Name="UOM_GUID" />
                <asp:Parameter Name="UnitsPerPackage" />
                <asp:Parameter Name="ApprovalDate" />
                <asp:Parameter Name="IntroductionDate" />
                <asp:Parameter Name="TerminationDate" />
                <asp:Parameter Name="ProductCode" />
                <asp:Parameter Name="Finance_ProductCode" />
                <asp:Parameter Name="RowGUID_Key" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource_WAC" runat="server" ConnectionString="<%$ ConnectionStrings:CIPAS.Web.Properties.Settings.CIPASCS %>" >
            <DeleteParameters>
                <asp:Parameter Name="RowGUID_Key" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="EffectiveDate" />
                <asp:Parameter Name="StartDate" />
                <asp:Parameter Name="EndDate" />
                <asp:Parameter Name="Price" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="EffectiveDate" />
                <asp:Parameter Name="StartDate" />
                <asp:Parameter Name="EndDate" />
                <asp:Parameter Name="Price" />
                <asp:Parameter Name="RowGUID_Key" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource_AMP" runat="server" ConnectionString="<%$ ConnectionStrings:CIPAS.Web.Properties.Settings.CIPASCS %>" />
        <asp:SqlDataSource ID="SqlDataSource_BAS" runat="server" ConnectionString="<%$ ConnectionStrings:CIPAS.Web.Properties.Settings.CIPASCS %>" />
        <asp:SqlDataSource ID="SqlDataSource_CMS" runat="server" ConnectionString="<%$ ConnectionStrings:CIPAS.Web.Properties.Settings.CIPASCS %>" />
     
        <telerik:RadGrid ID="RadGrid_Products" runat="server" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" 
                         AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
                         DataSourceID="SqlDataSource_Products" OnItemCommand="RadGrid_Products_ItemCommand" OnItemDataBound="RadGrid_Products_ItemDataBound"
                         >
            <MasterTableView DataKeyNames="RowGUID_Key" EditMode="PopUp" commanditemdisplay="Bottom">
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn_Products" />
                    <telerik:GridBoundColumn DataField="Name" FilterControlAltText="Filter Name column" HeaderText="Name" SortExpression="Name" UniqueName="Name" ItemStyle-Width="70%" />
                    <telerik:GridBoundColumn DataField="NDC" FilterControlAltText="Filter NDC column" HeaderText="NDC" SortExpression="NDC" UniqueName="NDC" ItemStyle-Width="10%" />
                    <telerik:GridBoundColumn DataField="NDC2" FilterControlAltText="Filter NDC2 column" HeaderText="NDC2" SortExpression="NDC2" UniqueName="NDC2" ItemStyle-Width="10%" />
                </Columns>
                <EditFormSettings EditColumn-UniqueName="EditCommandColumn_Products" EditFormType="Template" CaptionDataField="Name" PopUpSettings-ScrollBars="Auto" PopUpSettings-Modal="True" PopUpSettings-Height="768px" PopUpSettings-Width="1024px" PopUpSettings-ShowCaptionInEditForm="true">
                    <FormTemplate>
                        <table width="100%">
                            <tr>
                                <td width="10%" align="right">
                                    Name:
                                </td>
                                <td colspan="3">
                                    <telerik:RadTextBox ID="RadTextBox_Name" runat="server" width="100%" Text='<%# Bind("Name" ) %>' />
                                </td>
                            </tr>
                            <tr>
                                <td width="10%" align="right">
                                    NDC:
                                </td>
                                <td width="40%">
                                    <telerik:RadTextBox ID="RadTextBox_NDC" runat="server" width="100%" Text='<%# Bind("NDC" ) %>' />
                                </td>
                                <td width="10%" align="right">
                                    Approval Date:
                                </td>
                                <td width="40%">
                                    <telerik:RadDateInput ID="RadDateInput_ApprovalDate" runat="server" Width="100%" DBSelectedDate='<%# Bind("ApprovalDate" ) %>' />
                                </td>
                            </tr>
                            <tr>
                                <td width="10%" align="right">
                                    NDC2:
                                </td>
                                <td width="40%">
                                    <telerik:RadTextBox ID="RadTextBox_NDC2" runat="server" width="100%" Text='<%# Bind("NDC2" ) %>' />
                                </td>
                                <td width="10%" align="right">
                                    Intro Date:
                                </td>
                                <td width="40%">
                                    <telerik:RadDateInput ID="RadDateInput_IntroDate" runat="server" Width="100%" DBSelectedDate='<%# Bind("IntroductionDate" ) %>' />
                                </td>
                            </tr>
                            <tr>
                                <td width="10%" align="right">
                                    Form:
                                </td>
                                <td width="40%">
                                    <telerik:RadComboBox ID="RadComboBox_Form" runat="server" width="100%"
                                                         DataSourceID="SqlDataSource_Form"
                                                         DataTextField="Code"
                                                         DataValueField="RowGUID_Key" SelectedValue='<%# Bind("Form_GUID" ) %>' />
                                </td>
                                <td width="10%" align="right">
                                    Term Date:
                                </td>
                                <td width="40%">
                                    <telerik:RadDateInput ID="RadDateInput_TermDate" runat="server" Width="100%" DbSelectedDate='<%# Bind("TerminationDate" ) %>' />
                                </td>
                            </tr>
                            <tr>
                                <td width="10%" align="right">
                                    UOM:
                                </td>
                                <td width="40%">
                                    <telerik:RadComboBox ID="RadComboBox_UOM" runat="server" width="100%"
                                                         DataSourceID="SqlDataSource_UOM"
                                                         DataTextField="Code"
                                                         DataValueField="RowGUID_Key" SelectedValue='<%# Bind("UOM_GUID" ) %>' />
                                </td>
                                <td width="10%" align="right">
                                    Units/Pkg:
                                </td>
                                <td width="40%">
                                    <telerik:RadNumericTextBox ID="RadNumericTextBox_UnitsPerPkg" runat="server" Width="100%" Text='<%# Bind("UnitsPerPackage" ) %>' />
                                </td>
                            </tr>
                            <tr>
                                <td width="10%" align="right">
                                    Product Code:
                                </td>
                                <td width="40%">
                                    <telerik:RadTextBox ID="RadTextBox_ProductCode" runat="server" width="100%" Text='<%# Bind("ProductCode" ) %>' />
                                </td>
                                <td width="10%" align="right">
                                    Finance Product Code:
                                </td>
                                <td width="40%">
                                    <telerik:RadTextBox ID="RadTextBox_FinanceProductCode" runat="server" width="100%" Text='<%# Bind("Finance_ProductCode" ) %>' />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="4">
                                    <telerik:RadTabStrip ID="RadTabStrip_Pricing" runat="server" Width="100%" MultiPageID="RadMultiPage_Pricing" SelectedIndex="0" >
                                        <Tabs>
                                            <telerik:RadTab runat="server" Text="WAC Pricing" Selected="true" />
                                            <telerik:RadTab runat="server" Text="AMP Pricing" />
                                            <telerik:RadTab runat="server" Text="BAS Pricing" />
                                            <telerik:RadTab runat="server" Text="CMS Pricing" />
                                        </Tabs>
                                    </telerik:RadTabStrip>
                                    <telerik:RadMultiPage ID="RadMultiPage_Pricing" runat="server" SelectedIndex="0">
                                        <telerik:RadPageView ID="RadPageView_WAC" runat="server">
                                            <telerik:RadGrid ID="Inherit" DataKeyNames="RowGUID_Key" DataSourceID="SqlDataSource_WAC" Width="100%" runat="server" Name="WAC" OnItemCommand="Inherit_ItemCommand"
                                                 AutoGenerateColumns="False" CellSpacing="0" GridLines="None" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" >
                                                <MasterTableView DataSourceID="SqlDataSource_WAC" DataKeyNames="RowGUID_Key, Product_GUID" EditMode="InPlace" CommandItemDisplay="TopAndBottom">
                                                    <ParentTableRelation>
                                                        <telerik:GridRelationFields DetailKeyField="Product_GUID" MasterKeyField="RowGUID_Key"/>
                                                    </ParentTableRelation>
                                                    <Columns>
                                                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn_WAC" />
                                                        <telerik:GridBoundColumn DataField="EffectiveDate" DataType="System.DateTime" FilterControlAltText="Filter EffectiveDate column" HeaderText="EffectiveDate" SortExpression="EffectiveDate" UniqueName="EffectiveDate" DataFormatString="{0:d}" />
                                                        <telerik:GridBoundColumn DataField="StartDate" DataType="System.DateTime" FilterControlAltText="Filter StartDate column" HeaderText="StartDate" SortExpression="StartDate" UniqueName="StartDate" DataFormatString="{0:d}" />
                                                        <telerik:GridBoundColumn DataField="EndDate" DataType="System.DateTime" FilterControlAltText="Filter EndDate column" HeaderText="EndDate" SortExpression="EndDate" UniqueName="EndDate" DataFormatString="{0:d}" />
                                                        <telerik:GridBoundColumn DataField="Price" DataType="System.Decimal" FilterControlAltText="Filter Price column" HeaderText="Price" SortExpression="Price" UniqueName="Price" DataFormatString="{0:C2}" />
                                                    </Columns>
                                                    <EditFormSettings EditColumn-UniqueName="EditCommandColumn_WAC" EditColumn-ButtonType="ImageButton" EditFormType="AutoGenerated" />
                                                </MasterTableView>
                                            </telerik:RadGrid>
                                        </telerik:RadPageView>
                                        <telerik:RadPageView ID="RadPageView_AMP" runat="server">
                                        </telerik:RadPageView>
                                        <telerik:RadPageView ID="RadPageView_BAS" runat="server">
                                        </telerik:RadPageView>
                                        <telerik:RadPageView ID="RadPageView_CMS" runat="server">
                                        </telerik:RadPageView>
                                    </telerik:RadMultiPage>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="4">
                                    <br />
                                    <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'/>
                                      
                                    <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel" />
                                </td>
                            </tr>
                        </table>
                    </FormTemplate>
                </EditFormSettings>
            </MasterTableView>
        </telerik:RadGrid>
    </asp:Content>
















  2. ToltingColtAcres
    ToltingColtAcres avatar
    83 posts
    Member since:
    Nov 2010

    Posted 18 Dec 2013 Link to this post

    For yucks, to keep myself busy today, I rewrote the edit form as a web template... basically have the same issue, everything renders okay, until I click the pencil to edit a child grid row, then all the child data disappears.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1801 posts

    Posted 19 Dec 2013 Link to this post

    Hello Michael,

    I have tested the provided code snippet on my end with sample data and everything is working as expected on my end.

    Could you please try to temporarily disable the AJAX on your page and see if the same behavior is observable. 

    As a side note, please have in mind the RadGrid does not have "Name" nor "DataKeyNames" properties. "DataKeyNames" is a MasterTableView property. Furthermore, since you have ajaxified your grid, you should remove all nested AJAX settings from your RadAjaxManagerProxy:
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid_Products">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid_Products" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>

    For your convenience I have prepared a sample page, using your code snippet as reference, that works as expected on my end. Please refer to the attached files and see how it works on your side.

    I am looking forward to your reply with additional information about the result after disabling AJAX.


    Regards,
    Konstantin Dikov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  5. ToltingColtAcres
    ToltingColtAcres avatar
    83 posts
    Member since:
    Nov 2010

    Posted 19 Dec 2013 Link to this post

    Greetings Konstantin,


    I have used your sample, and as you said, it does work as expected.



    However, as I am going against an SQL data source for my information, it is necessary for some modifications, to allow the child grids to get their correct data.



    When I make these changes, I once again get symptom I previously describe. I click on master record pencil, I receive window with record and child tables populated correctly with data, but when I click pencil in child table to add record to child table, child table completely disappears.



    Grid1.png shows screen when clicking on first master record pencil. Everything is populated correctly. Clicking on 1st pencil in WAC child grid yields grid2.png picture.



    So, perhaps the issue is SQLdatasource, or how I am binding it? Or perhaps I should be handling a postback event when the child grid pencil is clicked? Here again is my new code based on your feedback, along with my code-behind.











    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestForm.aspx.cs" Inherits="CIPAS.Web.Admin.TestForm" %>
    <head>
    </head>
    <body runat="server">
        <form runat="server">
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                <Scripts>
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
                </Scripts>
            </telerik:RadScriptManager>
            <asp:SqlDataSource ID="SqlDataSource_Form" runat="server" ConnectionString="<%$ ConnectionStrings:CIPAS.Web.Properties.Settings.CIPASCS %>" SelectCommand="SELECT * FROM sysComboBoxValues WHERE ComboBox = 'FM' OR ComboBox = '' ORDER BY Code ASC" />
            <asp:SqlDataSource ID="SqlDataSource_UOM"  runat="server" ConnectionString="<%$ ConnectionStrings:CIPAS.Web.Properties.Settings.CIPASCS %>" SelectCommand="SELECT * FROM sysComboBoxValues WHERE ComboBox = 'UM' OR ComboBox = '' ORDER BY Code ASC" />
            <asp:SqlDataSource ID="SqlDataSource_Products" runat="server"
                               ConnectionString="<%$ ConnectionStrings:CIPAS.Web.Properties.Settings.CIPASCS %>"
                               InsertCommand="INSERT INTO ProductAdministration_Products (RowGUID_Key, NDC, NDC2, Name, Form_GUID, UOM_GUID, UnitsPerPackage, ApprovalDate, IntroductionDate, TerminationDate, ProductCode, Finance_ProductCode, UpdatedOn, UpdatedBy, sysRevision) VALUES (NEWID(), @NDC, @NDC2, @Name, @Form_GUID, @UOM_GUID, @UnitsPerPackage, @ApprovalDate, @IntroductionDate, @TerminationDate, @ProductCode, @Finance_ProductCode, GETDATE(), dbo.udf_GetEmployeeGUID(SUSER_NAME()), 0)"
                               SelectCommand="SELECT * FROM ProductAdministration_Products"
                               UpdateCommand="UPDATE ProductAdministration_Products SET NDC = @NDC, NDC2 = @NDC2, Name = @Name, Form_GUID = @Form_GUID, UOM_GUID = @UOM_GUID, UnitsPerPackage = @UnitsPerPackage, ApprovalDate = @ApprovalDate, IntroductionDate = @IntroductionDate, TerminationDate = @TerminationDate, ProductCode = @ProductCode, Finance_ProductCode = @Finance_ProductCode, UpdatedOn = GETDATE(), UpdatedBy = dbo.udf_GetEmployeeGUID(SUSER_NAME()), sysRevision = sysRevision + 1 WHERE RowGUID_Key = @RowGUID_Key" >
                <InsertParameters>
                    <asp:Parameter Name="NDC" />
                    <asp:Parameter Name="NDC2" />
                    <asp:Parameter Name="Name" />
                    <asp:Parameter Name="Form_GUID" />
                    <asp:Parameter Name="UOM_GUID" />
                    <asp:Parameter Name="UnitsPerPackage" />
                    <asp:Parameter Name="ApprovalDate" />
                    <asp:Parameter Name="IntroductionDate" />
                    <asp:Parameter Name="TerminationDate" />
                    <asp:Parameter Name="ProductCode" />
                    <asp:Parameter Name="Finance_ProductCode" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="NDC" />
                    <asp:Parameter Name="NDC2" />
                    <asp:Parameter Name="Name" />
                    <asp:Parameter Name="Form_GUID" />
                    <asp:Parameter Name="UOM_GUID" />
                    <asp:Parameter Name="UnitsPerPackage" />
                    <asp:Parameter Name="ApprovalDate" />
                    <asp:Parameter Name="IntroductionDate" />
                    <asp:Parameter Name="TerminationDate" />
                    <asp:Parameter Name="ProductCode" />
                    <asp:Parameter Name="Finance_ProductCode" />
                    <asp:Parameter Name="RowGUID_Key" />
                </UpdateParameters>
            </asp:SqlDataSource>
     
            <asp:SqlDataSource ID="SqlDataSource_WAC" runat="server" ConnectionString="<%$ ConnectionStrings:CIPAS.Web.Properties.Settings.CIPASCS %>">
                <DeleteParameters>
                    <asp:Parameter Name="RowGUID_Key" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="EffectiveDate" />
                    <asp:Parameter Name="StartDate" />
                    <asp:Parameter Name="EndDate" />
                    <asp:Parameter Name="Price" />
                </InsertParameters>
                <SelectParameters>
                </SelectParameters>
                <UpdateParameters>
                    <asp:Parameter Name="EffectiveDate" />
                    <asp:Parameter Name="StartDate" />
                    <asp:Parameter Name="EndDate" />
                    <asp:Parameter Name="Price" />
                    <asp:Parameter Name="RowGUID_Key" />
                </UpdateParameters>
            </asp:SqlDataSource>
     
            <asp:SqlDataSource ID="SqlDataSource_AMP" runat="server" ConnectionString="<%$ ConnectionStrings:CIPAS.Web.Properties.Settings.CIPASCS %>" />
            <asp:SqlDataSource ID="SqlDataSource_BAS" runat="server" ConnectionString="<%$ ConnectionStrings:CIPAS.Web.Properties.Settings.CIPASCS %>" />
            <asp:SqlDataSource ID="SqlDataSource_CMS" runat="server" ConnectionString="<%$ ConnectionStrings:CIPAS.Web.Properties.Settings.CIPASCS %>" />
     
            <telerik:RadGrid ID="RadGrid_Products" runat="server" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" onItemDataBound="RadGrid_Products_ItemDataBound"
                             AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
                             DataSourceID="SqlDataSource_Products" style="margin-bottom: 40px"
                             >
                <MasterTableView DataKeyNames="RowGUID_Key" EditMode="PopUp" commanditemdisplay="Bottom">
                    <Columns>
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn_Products" />
                        <telerik:GridBoundColumn DataField="Name" FilterControlAltText="Filter Name column" HeaderText="Name" SortExpression="Name" UniqueName="Name" ItemStyle-Width="70%" />
                        <telerik:GridBoundColumn DataField="NDC" FilterControlAltText="Filter NDC column" HeaderText="NDC" SortExpression="NDC" UniqueName="NDC" ItemStyle-Width="10%" />
                        <telerik:GridBoundColumn DataField="NDC2" FilterControlAltText="Filter NDC2 column" HeaderText="NDC2" SortExpression="NDC2" UniqueName="NDC2" ItemStyle-Width="10%" />
                    </Columns>
                    <EditFormSettings EditColumn-UniqueName="EditCommandColumn_Products" EditFormType="Template" CaptionDataField="Name" PopUpSettings-ScrollBars="Auto" PopUpSettings-Modal="True" PopUpSettings-Height="768px" PopUpSettings-Width="1024px" PopUpSettings-ShowCaptionInEditForm="true">
                        <FormTemplate>
                            <table width="100%">
                                <tr>
                                    <td width="10%" align="right">
                                        Name:
                                    </td>
                                    <td colspan="3">
                                        <telerik:RadTextBox ID="RadTextBox_Name" runat="server" width="100%" Text='<%# Bind("Name" ) %>' />
                                    </td>
                                </tr>
                                <tr>
                                    <td width="10%" align="right">
                                        NDC:
                                    </td>
                                    <td width="40%">
                                        <telerik:RadTextBox ID="RadTextBox_NDC" runat="server" width="100%" Text='<%# Bind("NDC" ) %>' />
                                    </td>
                                    <td width="10%" align="right">
                                        Approval Date:
                                    </td>
                                    <td width="40%">
                                        <telerik:RadDateInput ID="RadDateInput_ApprovalDate" runat="server" Width="100%" DBSelectedDate='<%# Bind("ApprovalDate" ) %>' />
                                    </td>
                                </tr>
                                <tr>
                                    <td width="10%" align="right">
                                        NDC2:
                                    </td>
                                    <td width="40%">
                                        <telerik:RadTextBox ID="RadTextBox_NDC2" runat="server" width="100%" Text='<%# Bind("NDC2" ) %>' />
                                    </td>
                                    <td width="10%" align="right">
                                        Intro Date:
                                    </td>
                                    <td width="40%">
                                        <telerik:RadDateInput ID="RadDateInput_IntroDate" runat="server" Width="100%" DBSelectedDate='<%# Bind("IntroductionDate" ) %>' />
                                    </td>
                                </tr>
                                <tr>
                                    <td width="10%" align="right">
                                        Form:
                                    </td>
                                    <td width="40%">
                                        <telerik:RadComboBox ID="RadComboBox_Form" runat="server" width="100%"
                                                             DataSourceID="SqlDataSource_Form"
                                                             DataTextField="Code"
                                                             DataValueField="RowGUID_Key" SelectedValue='<%# Bind("Form_GUID" ) %>' />
                                    </td>
                                    <td width="10%" align="right">
                                        Term Date:
                                    </td>
                                    <td width="40%">
                                        <telerik:RadDateInput ID="RadDateInput_TermDate" runat="server" Width="100%" DbSelectedDate='<%# Bind("TerminationDate" ) %>' />
                                    </td>
                                </tr>
                                <tr>
                                    <td width="10%" align="right">
                                        UOM:
                                    </td>
                                    <td width="40%">
                                        <telerik:RadComboBox ID="RadComboBox_UOM" runat="server" width="100%"
                                                             DataSourceID="SqlDataSource_UOM"
                                                             DataTextField="Code"
                                                             DataValueField="RowGUID_Key" SelectedValue='<%# Bind("UOM_GUID" ) %>' />
                                    </td>
                                    <td width="10%" align="right">
                                        Units/Pkg:
                                    </td>
                                    <td width="40%">
                                        <telerik:RadNumericTextBox ID="RadNumericTextBox_UnitsPerPkg" runat="server" Width="100%" Text='<%# Bind("UnitsPerPackage" ) %>' />
                                    </td>
                                </tr>
                                <tr>
                                    <td width="10%" align="right">
                                        Product Code:
                                    </td>
                                    <td width="40%">
                                        <telerik:RadTextBox ID="RadTextBox_ProductCode" runat="server" width="100%" Text='<%# Bind("ProductCode" ) %>' />
                                    </td>
                                    <td width="10%" align="right">
                                        Finance Product Code:
                                    </td>
                                    <td width="40%">
                                        <telerik:RadTextBox ID="RadTextBox_FinanceProductCode" runat="server" width="100%" Text='<%# Bind("Finance_ProductCode" ) %>' />
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="4">
                                        <telerik:RadTabStrip ID="RadTabStrip_Pricing" runat="server" Width="100%" MultiPageID="RadMultiPage_Pricing" SelectedIndex="0" >
                                            <Tabs>
                                                <telerik:RadTab runat="server" Text="WAC Pricing" Selected="true" />
                                                <telerik:RadTab runat="server" Text="AMP Pricing" />
                                                <telerik:RadTab runat="server" Text="BAS Pricing" />
                                                <telerik:RadTab runat="server" Text="CMS Pricing" />
                                            </Tabs>
                                        </telerik:RadTabStrip>
                                        <telerik:RadMultiPage ID="RadMultiPage_Pricing" runat="server" SelectedIndex="0" Width="100%" >
                                            <telerik:RadPageView ID="RadPageView_WAC" runat="server">
                                                <telerik:RadGrid ID="RadGrid_WAC" DataKeyNames="RowGUID_Key" DataSourceID="SqlDataSource_WAC" Width="100%" runat="server" Name="WAC"
                                                                 AutoGenerateColumns="False" CellSpacing="0" GridLines="None" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" >
                                                    <MasterTableView  DataKeyNames="RowGUID_Key, Product_GUID" EditMode="InPlace" CommandItemDisplay="TopAndBottom">
                                                        <ParentTableRelation>
                                                            <telerik:GridRelationFields DetailKeyField="Product_GUID" MasterKeyField="RowGUID_Key"/>
                                                        </ParentTableRelation>
                                                        <Columns>
                                                            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn_WAC" />
                                                            <telerik:GridBoundColumn DataField="EffectiveDate" DataType="System.DateTime" FilterControlAltText="Filter EffectiveDate column" HeaderText="EffectiveDate" SortExpression="EffectiveDate" UniqueName="EffectiveDate" DataFormatString="{0:d}" />
                                                            <telerik:GridBoundColumn DataField="StartDate" DataType="System.DateTime" FilterControlAltText="Filter StartDate column" HeaderText="StartDate" SortExpression="StartDate" UniqueName="StartDate" DataFormatString="{0:d}" />
                                                            <telerik:GridBoundColumn DataField="EndDate" DataType="System.DateTime" FilterControlAltText="Filter EndDate column" HeaderText="EndDate" SortExpression="EndDate" UniqueName="EndDate" DataFormatString="{0:d}" />
                                                            <telerik:GridBoundColumn DataField="Price" DataType="System.Decimal" FilterControlAltText="Filter Price column" HeaderText="Price" SortExpression="Price" UniqueName="Price" DataFormatString="{0:C2}" />
                                                        </Columns>
                                                        <EditFormSettings EditColumn-UniqueName="EditCommandColumn_WAC" EditColumn-ButtonType="ImageButton" EditFormType="AutoGenerated" />
                                                    </MasterTableView>
                                                </telerik:RadGrid>
                                            </telerik:RadPageView>
                                            <telerik:RadPageView ID="RadPageView_AMP" runat="server">
                                                <telerik:RadGrid ID="RadGrid_AMP" DataKeyNames="RowGUID_Key" DataSourceID="SqlDataSource_AMP" Width="100%" runat="server" Name="AMP"
                                                                 AutoGenerateColumns="False" CellSpacing="0" GridLines="None" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" >
                                                    <MasterTableView  DataKeyNames="RowGUID_Key, Product_GUID" EditMode="InPlace" CommandItemDisplay="TopAndBottom">
                                                        <ParentTableRelation>
                                                            <telerik:GridRelationFields DetailKeyField="Product_GUID" MasterKeyField="RowGUID_Key"/>
                                                        </ParentTableRelation>
                                                        <Columns>
                                                            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn_AMP" />
                                                            <telerik:GridBoundColumn DataField="EffectiveDate" DataType="System.DateTime" FilterControlAltText="Filter EffectiveDate column" HeaderText="EffectiveDate" SortExpression="EffectiveDate" UniqueName="EffectiveDate" DataFormatString="{0:d}" />
                                                            <telerik:GridBoundColumn DataField="StartDate" DataType="System.DateTime" FilterControlAltText="Filter StartDate column" HeaderText="StartDate" SortExpression="StartDate" UniqueName="StartDate" DataFormatString="{0:d}" />
                                                            <telerik:GridBoundColumn DataField="EndDate" DataType="System.DateTime" FilterControlAltText="Filter EndDate column" HeaderText="EndDate" SortExpression="EndDate" UniqueName="EndDate" DataFormatString="{0:d}" />
                                                            <telerik:GridBoundColumn DataField="Price" DataType="System.Decimal" FilterControlAltText="Filter Price column" HeaderText="Price" SortExpression="Price" UniqueName="Price" DataFormatString="{0:C2}" />
                                                        </Columns>
                                                        <EditFormSettings EditColumn-UniqueName="EditCommandColumn_AMP" EditColumn-ButtonType="ImageButton" EditFormType="AutoGenerated" />
                                                    </MasterTableView>
                                                </telerik:RadGrid>
                                            </telerik:RadPageView>
                                            <telerik:RadPageView ID="RadPageView_BAS" runat="server">
                                                <telerik:RadGrid ID="RadGrid_BAS" DataKeyNames="RowGUID_Key" DataSourceID="SqlDataSource_BAS" Width="100%" runat="server" Name="BAS"
                                                                 AutoGenerateColumns="False" CellSpacing="0" GridLines="None" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" >
                                                    <MasterTableView DataKeyNames="RowGUID_Key, Product_GUID" EditMode="InPlace" CommandItemDisplay="TopAndBottom">
                                                        <ParentTableRelation>
                                                            <telerik:GridRelationFields DetailKeyField="Product_GUID" MasterKeyField="RowGUID_Key"/>
                                                        </ParentTableRelation>
                                                        <Columns>
                                                            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn_BAS" />
                                                            <telerik:GridBoundColumn DataField="EffectiveDate" DataType="System.DateTime" FilterControlAltText="Filter EffectiveDate column" HeaderText="EffectiveDate" SortExpression="EffectiveDate" UniqueName="EffectiveDate" DataFormatString="{0:d}" />
                                                            <telerik:GridBoundColumn DataField="StartDate" DataType="System.DateTime" FilterControlAltText="Filter StartDate column" HeaderText="StartDate" SortExpression="StartDate" UniqueName="StartDate" DataFormatString="{0:d}" />
                                                            <telerik:GridBoundColumn DataField="EndDate" DataType="System.DateTime" FilterControlAltText="Filter EndDate column" HeaderText="EndDate" SortExpression="EndDate" UniqueName="EndDate" DataFormatString="{0:d}" />
                                                            <telerik:GridBoundColumn DataField="Price" DataType="System.Decimal" FilterControlAltText="Filter Price column" HeaderText="Price" SortExpression="Price" UniqueName="Price" DataFormatString="{0:C2}" />
                                                        </Columns>
                                                        <EditFormSettings EditColumn-UniqueName="EditCommandColumn_BAS" EditColumn-ButtonType="ImageButton" EditFormType="AutoGenerated" />
                                                    </MasterTableView>
                                                </telerik:RadGrid>
                                            </telerik:RadPageView>
                                            <telerik:RadPageView ID="RadPageView_CMS" runat="server">
                                                <telerik:RadGrid ID="RadGrid_CMS" DataKeyNames="RowGUID_Key" DataSourceID="SqlDataSource_CMS" Width="100%" runat="server" Name="CMS"
                                                                 AutoGenerateColumns="False" CellSpacing="0" GridLines="None" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" >
                                                    <MasterTableView  DataKeyNames="RowGUID_Key, Product_GUID" EditMode="InPlace" CommandItemDisplay="TopAndBottom">
                                                        <ParentTableRelation>
                                                            <telerik:GridRelationFields DetailKeyField="Product_GUID" MasterKeyField="RowGUID_Key"/>
                                                        </ParentTableRelation>
                                                        <Columns>
                                                            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn_CMS" />
                                                            <telerik:GridBoundColumn DataField="EffectiveDate" DataType="System.DateTime" FilterControlAltText="Filter EffectiveDate column" HeaderText="EffectiveDate" SortExpression="EffectiveDate" UniqueName="EffectiveDate" DataFormatString="{0:d}" />
                                                            <telerik:GridBoundColumn DataField="StartDate" DataType="System.DateTime" FilterControlAltText="Filter StartDate column" HeaderText="StartDate" SortExpression="StartDate" UniqueName="StartDate" DataFormatString="{0:d}" />
                                                            <telerik:GridBoundColumn DataField="EndDate" DataType="System.DateTime" FilterControlAltText="Filter EndDate column" HeaderText="EndDate" SortExpression="EndDate" UniqueName="EndDate" DataFormatString="{0:d}" />
                                                            <telerik:GridBoundColumn DataField="Price" DataType="System.Decimal" FilterControlAltText="Filter Price column" HeaderText="Price" SortExpression="Price" UniqueName="Price" DataFormatString="{0:C2}" />
                                                        </Columns>
                                                        <EditFormSettings EditColumn-UniqueName="EditCommandColumn_CMS" EditColumn-ButtonType="ImageButton" EditFormType="AutoGenerated" />
                                                    </MasterTableView>
                                                </telerik:RadGrid>
                                            </telerik:RadPageView>
                                        </telerik:RadMultiPage>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="4">
                                        <br />
                                        <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'/>
                                        <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel" />
                                    </td>
                                </tr>
                            </table>
                        </FormTemplate>
                    </EditFormSettings>
                </MasterTableView>
            </telerik:RadGrid>
        </form>
    </body>












    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
     
    namespace CIPAS.Web.Admin
    {
        public partial class TestForm : System.Web.UI.Page
        {
            protected void RadGrid_Products_ItemDataBound(object sender, GridItemEventArgs e)
            {
                if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
                {
                    GridEditFormItem item = (GridEditFormItem)e.Item;
                    String str = item.GetDataKeyValue("RowGUID_Key").ToString();
                    this.SqlDataSource_WAC.DeleteCommand = "DELETE FROM ProductAdministration_Pricing WHERE RowGUID_Key = @RowGUID_Key";
                    this.SqlDataSource_WAC.InsertCommand = "INSERT INTO ProductAdministration_Pricing (RowGUID_Key, Product_GUID, EffectiveDate,  StartDate,  EndDate,  Price, RateIndicator, UpdatedOn, UpdatedBy, sysRevision) VALUES (NEWID(), '" + str + "', @EffectiveDate, @StartDate, @EndDate, @Price, 'W', GETDATE(), dbo.udf_GetEmployeeGUID(SUSER_NAME()), 0)";
                    this.SqlDataSource_WAC.SelectCommand = "SELECT * FROM ProductAdministration_Pricing WHERE (RateIndicator ='W' AND Product_GUID = '" + str + "') ORDER BY EffectiveDate DESC";
                    this.SqlDataSource_WAC.UpdateCommand = "UPDATE ProductAdministration_Pricing SET EffectiveDate = @EffectiveDate, StartDate = @StartDate, EndDate = @EndDate, Price = @Price, UpdatedOn = GETDATE(), UpdatedBy = dbo.udf_GetEmployeeGUID(SUSER_NAME()), sysRevision = sysRevision + 1 WHERE RowGUID_Key = @RowGUID_Key";
                    this.SqlDataSource_AMP.SelectCommand = "SELECT * FROM ProductAdministration_Pricing WHERE (RateIndicator ='A' AND Product_GUID = '" + str + "') ORDER BY EffectiveDate DESC";
                    this.SqlDataSource_BAS.SelectCommand = "SELECT * FROM ProductAdministration_Pricing WHERE (RateIndicator ='B' AND Product_GUID = '" + str + "') ORDER BY EffectiveDate DESC";
                    this.SqlDataSource_CMS.SelectCommand = "SELECT * FROM ProductAdministration_Pricing WHERE (RateIndicator ='C' AND Product_GUID = '" + str + "') ORDER BY EffectiveDate DESC";
                    this.SqlDataSource_WAC.Select(DataSourceSelectArguments.Empty);
                    this.SqlDataSource_AMP.Select(DataSourceSelectArguments.Empty);
                    this.SqlDataSource_BAS.Select(DataSourceSelectArguments.Empty);
                    this.SqlDataSource_CMS.Select(DataSourceSelectArguments.Empty);
                    ((RadGrid)item.FindControl("RadGrid_WAC")).Rebind();
                    ((RadGrid)item.FindControl("RadGrid_AMP")).Rebind();
                    ((RadGrid)item.FindControl("RadGrid_BAS")).Rebind();
                    ((RadGrid)item.FindControl("RadGrid_CMS")).Rebind();
                }
            }
        }
    }




  6. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1801 posts

    Posted 24 Dec 2013 Link to this post

    Hello Michael,

    I have examine again the provided code snippets and I was able to locate the root of the problem. Since you do not have SelectCommand in the SqlDataSource controls for your inner grids and due to the fact that the ItemDataBound event for the parent grid will fire only once while in edit mode, after a postback from the child occurs, there is no select command assigned for the SqlDataSource controls and no data is retrieved.

    What you can do for your scenario is to handle the child grids server-side Load event for example, get reference to the parent GridEditFormItem and retrieve the data key, so you could assign the select command.
    protected void RadGrid_WAC_Load(object sender, EventArgs e)
    {
        GridEditFormItem item = (sender as RadGrid).NamingContainer as GridEditFormItem;
        String str = item.GetDataKeyValue("RowGUID_Key").ToString();
        this.SqlDataSource_WAC.SelectCommand = "SELECT * FROM ProductAdministration_Pricing WHERE (RateIndicator ='W' AND Product_GUID = '" + str + "') ORDER BY EffectiveDate DESC";
        this.SqlDataSource_WAC.Select(DataSourceSelectArguments.Empty);
        //(item.FindControl("Inherit") as RadGrid).Rebind();
    }

    I have tested this with your setting and it is working as expected. 


    Regards,
    Konstantin Dikov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  7. ToltingColtAcres
    ToltingColtAcres avatar
    83 posts
    Member since:
    Nov 2010

    Posted 24 Dec 2013 Link to this post

    Konstantin, you are a genius! Works like a charm! Thank you for all your assistance. +rep if I had the option!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017