This is a migrated thread and some comments may be shown as answers.

Using A WebControl to edit records radgrid hierarchy

2 Answers 15 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Perry
Top achievements
Rank 1
Perry asked on 21 Jun 2019, 04:58 PM

I have a Hierarchy grid with a using a Master TableView and one DetailTable that looks like this

 

<telerik:RadGrid runat="server" ID="PrintRadGrid" OnDetailTableDataBind="PrintRadGrid_DetailTableDataBind"
                                AutoGenerateColumns="false" OnPageIndexChanged="PrintRadGrid_PageIndexChanged" OnPageSizeChanged="PrintRadGrid_PageSizeChanged"
                                GroupPanelPosition="Top" OnUpdateCommand="PrintRadGrid_UpdateCommand" OnInsertCommand="PrintRadGrid_InsertCommand"
                                AllowPaging="true"  OnNeedDataSource="PrintRadGrid_NeedDataSource">
                                <GroupingSettings CollapseAllTooltip="Collapse all groups" />
                                <PagerStyle Mode="NextPrevAndNumeric" />
                                <MasterTableView CommandItemDisplay="Top" DataKeyNames="CaseId_Fk,LatentsId" HierarchyDefaultExpanded="false" RetainExpandStateOnRebind="true">
                                    <Columns>
                                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="PrintsEditCommandColumn"></telerik:GridEditCommandColumn>
                                        <telerik:GridDateTimeColumn DataField="SubmittedDate" HeaderText="Submitted Date" SortExpression="SubmittedDate"
                                            PickerType="DatePicker" EnableTimeIndependentFiltering="true" DataFormatString="{0:MM/dd/yyyy}">
                                        </telerik:GridDateTimeColumn>
                                        <telerik:GridBoundColumn UniqueName="SubmittedBy" HeaderText="Submitted By" DataField="SubmittedBY"></telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="SubmittedByNoneOCSO" HeaderText="Submitted By None Employee" DataField="SubmittedByNoneOcso"></telerik:GridBoundColumn>
                                        <telerik:GridTemplateColumn AllowFiltering="false">
                                                    <ItemTemplate>
                                                        <asp:Button ID="btnDeleteParent" CssClass="btn btn-xs btn-danger" Text="Delete" runat="server" OnClick="btnDeletePrintParent_Click" OnClientClick="confirmAspButton(this); return false;"></asp:Button>
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>
                                    </Columns>
                                    <DetailTables>
                                        <telerik:GridTableView Name="PrintsLiftedGrid" Width="100%" DataKeyNames="LatentsId_FK"
                                             CommandItemDisplay="Top" EnableNoRecordsTemplate="true" HierarchyDefaultExpanded="false">
                                            <NoRecordsTemplate>
                                                <asp:Label ID="Label8" runat="server" CssClass="label" Text="No charges have been added." />
                                            </NoRecordsTemplate>
                                            <Columns>
                                                <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                                                 </telerik:GridEditCommandColumn>
                                                <telerik:GridDateTimeColumn DataField="LiftedDate" HeaderText="Lifted Date Date" SortExpression="LiftedDate"
                                                    PickerType="DatePicker" EnableTimeIndependentFiltering="true" DataFormatString="{0:MM/dd/yyyy}">
                                                </telerik:GridDateTimeColumn>
                                                <telerik:GridBoundColumn UniqueName="ExhibitNum" HeaderText="Exhibit Number" DataField="ExhibitNum"></telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="LocationLifted" HeaderText="Location Lifted" DataField="LocationLifted"></telerik:GridBoundColumn>
                                                <telerik:GridTemplateColumn AllowFiltering="false">
                                                    <ItemTemplate>
                                                        <asp:Button ID="btnDeletePrintChild" CssClass="btn btn-xs btn-danger" Text="Delete" runat="server" OnClick="btnDeletePrintChild_Click" OnClientClick="confirmAspButton(this); return false;"></asp:Button>
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>
                                             </Columns>
                                            <CommandItemStyle BackColor="#AfAFa4" Font-Bold="true" Height="50px"
                                                VerticalAlign="Bottom" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" />
                                            <CommandItemTemplate>
                                                <div class="boldLabel"> Prints</div>
                                                <asp:Button runat="server" ID="lbAddPrint" Text="ADD NEW PRINT" CommandName="InitInsert"
                                                    CssClass="rgButtonText" CausesValidation="false" />
                                            </CommandItemTemplate>
                                            <ParentTableRelation>
                                                <telerik:GridRelationFields DetailKeyField="LatentsId_FK" MasterKeyField="LatentsId" />
                                            </ParentTableRelation>
                                        </telerik:GridTableView>

 

In the MasterTable View and the the DetailTable I want to use a web control for Inserting and Updating the records.  I have tried adding this code:

<EditFormSettings UserControlName="SubjectEdit.ascx" EditFormType="WebUserControl" PopUpSettings-Modal="false">
                                                <EditColumn UniqueName="EditCommandColumn1"></EditColumn>
                                            </EditFormSettings>

 

Put keep getting this  error :Telerik.Web.UI.GridTableViewCollection must have items of type 'Telerik.Web.UI.GridTableView'. 'EditFormSettings' is of type 'System.Web.UI.HtmlControls.HtmlGenericControl'.

What is the syntax to use the web control page and where within MasterTableView and DetailTableView do I put it?

2 Answers, 1 is accepted

Sort by
0
Accepted
Attila Antal
Telerik team
answered on 26 Jun 2019, 09:57 AM
Hi Perry,

The code snippet you have shared does not contain the entire setup, hence I am unable to identify the issue. Nevertheless I will show you a working example below:

<telerik:RadGrid ID="RadGrid1" runat="server">
    <MasterTableView EditMode="PopUp">
        <EditFormSettings EditFormType="WebUserControl" UserControlName="program.ascx">
        </EditFormSettings>
        <DetailTables>
            <telerik:GridTableView EditMode="PopUp">
                <EditFormSettings EditFormType="WebUserControl" UserControlName="program.ascx">
                </EditFormSettings>
            </telerik:GridTableView>
        </DetailTables>
        <Columns>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

Additionally to the Syntax, I would also suggest double-checking the project and ensure that no Control has the ID of "EditFormSettings" and also there aren't any custom classes with that name. They can conflict and produce the described issue.

Kind regards,
Attila Antal
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Perry
Top achievements
Rank 1
answered on 26 Jun 2019, 12:25 PM
Thank you very much Attila, this was exactly what I needed.
Tags
Grid
Asked by
Perry
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Perry
Top achievements
Rank 1
Share this question
or