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

[Solved] Update details table using usercontrol edit

1 Answer 50 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marty
Top achievements
Rank 1
Marty asked on 24 Jan 2013, 05:47 PM
I have a radgrid with a details table. Both the master table and the details table are using usercontrols for the edit/insert capbilities. Below is the code of the main grid page (I have stripped out unrelated sections):

<telerik:RadGrid ID="grdLibraryGlobalRates" runat="server"  DataSourceID="dsLibraryGlobalRateManager"
                                                                    AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True">
     <MasterTableView CommandItemDisplay="Top" DataSourceID="dsLibraryGlobalRateManager"  
            DataKeyNames="_LibraryGlobalRateScheduleID">

                <DetailTables>
                    <telerik:GridTableView Name="grdGlobalRateScheduleEvent"
                                DataKeyNames="_LibraryGlobalRateScheduleEventID"                 
                                DataSourceID="dsLibraryGlobalRateManagerEvent" Width="100%"
                                 runat="server" AutoGenerateColumns="False"  CommandItemDisplay="Top">
                                 <ParentTableRelation>
                                        <telerik:GridRelationFields DetailKeyField="_LibraryGlobalRateScheduleID"         
                                            MasterKeyField="_LibraryGlobalRateScheduleID"></telerik:GridRelationFields>
                                 </ParentTableRelation>
                                 .............. Columns here
                                <EditFormSettings EditFormType="WebUserControl"     
                                            UserControlName="UserControls_EditUpdate/LibraryGlobalRateEvents.ascx">
                                                <EditColumn FilterControlAltText="Filter EditCommandColumn1 column"     
                                                UniqueName="EditCommandColumn1">
                                                </EditColumn>
                                </EditFormSettings>
                     </telerik:GridTableView>
             </DetailTables>
            ............Columns here
        <EditFormSettings EditFormType="WebUserControl" UserControlName="UserControls_EditUpdate/LibraryGlobalRates.ascx">
             <EditColumn FilterControlAltText="Filter EditCommandColumn1 column" UniqueName="EditCommandColumn1">
            </EditColumn>
         </EditFormSettings>
    </MasterTableView>
</telerik:RadGrid>


I have put command names on the update (LibraryGlobalRateEventUpdate) and insert (LibraryGlobalRateEventInsert) buttons on the usercontrol for the details table update. on the main grid item command event I evaluate for the command name and proceed accordingly in the code behind:

 

Protected Sub grdLibraryGlobalRates_ItemCommand(sender As Object, e As GridCommandEventArgs) Handles grdLibraryGlobalRates.ItemCommand

If e.CommandName = "LibraryGlobalRateEventUpdate" Then

Try

Dim MyUserControl As UserControl = CType(e.Item.FindControl(Telerik.Web.UI.GridEditFormItem.EditFormUserControlID), UserControl)

End If

 

If e.CommandName = "LibraryGlobalRateEventInsert" Then

 Try

  Dim MyUserControl As UserControl = CType(e.Item.FindControl(Telerik.Web.UI.GridEditFormItem.EditFormUserControlID), UserControl)

End If

End Sub

 

On the LibraryGlobalRateEventInsert command, e.item evaluates to

{Telerik.Web.UI.GridEditFormInsertItem} and MyUserControl gets set to the usercontrol I am using for the EditFormSettings

On the LibraryGlobalRateEventUpdate command, e.item evaluates to

{Telerik.Web.UI.GridDataItem} and MyUserControl gets set to Nothing

At this point I am unable to update values when edit is selected.

Please help me resolve this or point me to a post that will explain the update process for details tables as it pertains to UserControls for editing.

Thanks,
Marty

 

 

 

 

 

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 29 Jan 2013, 04:09 PM
Hi Marty,

I would suggest you to review the online demo below which presents User Control data editing for detail tables:

http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/linqdatasource/defaultcs.aspx

I hope this helps.

Kind regards,
Maria Ilieva
the Telerik team
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 their blog feed now.
Tags
Grid
Asked by
Marty
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or