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

custom control with radgrid inside edit radgrid template

6 Answers 197 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Borislava
Top achievements
Rank 1
Borislava asked on 19 Nov 2013, 02:54 PM
i have custom control with radgrid inside edit radgrid template.
none of the updates/insert/deletes in custom control not working. could you explain why and how to fix it

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 Nov 2013, 09:51 AM
Hi Borislava,

I guess you are using a WebUserControl EditForm inside Radgrid. Please go through this Demo which shows operations performed in a RadGrid using WebUserControl form. If this doesn't help, please provide your full code snippet.

Thanks,
Princy


0
Borislava
Top achievements
Rank 1
answered on 20 Nov 2013, 01:41 PM

<telerik:RadGrid ID="rgGroups" ...>...
 <EditFormSettings EditFormType="Template">
            <FormTemplate>
  .....
   <uc2:Campuses runat="server" ID="Campuses" />
  <asp:TextBox......
      </FormTemplate>...
</telerik:RadGrid>

and code behind
 Private Sub rgGroups_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgGroups.ItemCreated
        If TypeOf e.Item Is GridEditableItem And e.Item.IsInEditMode Then
            If TypeOf e.Item Is GridEditFormInsertItem OrElse TypeOf e.Item Is GridDataInsertItem Then
                ' insert item
                Dim editform As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
                Dim Campuses As Campuses = CType(e.Item.FindControl("Campuses"), Campuses)
                Campuses.MakeInit(Nothing)
            Else
                ' edit item
                Dim editform As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
                Dim Campuses As Campuses = CType(e.Item.FindControl("Campuses"), Campuses)
                Campuses.MakeInit(editform.GetDataKeyValue("GroupID"))
            End If
        End If

<uc2:Campuses> is a webUser control with RadGrid which should allow to edit/add/delete:  allow to perform action while rgGroups is in edit mode .
When I am trying to add a new item in webUser control it goes  to userControl load page
but don't fire an event (Insert/update).why?

0
Princy
Top achievements
Rank 2
answered on 21 Nov 2013, 04:37 AM
Hi Borislava,

Below is a sample code snippet that i tried which works fine at my end. With your given code its hard to identify the cause of the problem. Please try the sample code snippet, add the UserControl as follows and see if it helps, else provide your full code.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" . . .>
    <MasterTableView. . .>     
        <EditFormSettings UserControlName="EditPopup.ascx" EditFormType="WebUserControl"
            EditColumn-UniqueName="EditCommandColumn1">
        </EditFormSettings>
    </MasterTableView>
</telerik:RadGrid>

ASCX:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateEditColumn="true" AutoGenerateDeleteColumn="true"
    OnInsertCommand="RadGrid1_InsertCommand">
    <MasterTableView DataKeyNames="ID" CommandItemDisplay="Top">
        <Columns>
         . . . .
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

ASCX:CS:
Protected Sub RadGrid1_InsertCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.InsertCommand
    'Code to insert
   End Sub

Thanks,
Princy
0
Borislava
Top achievements
Rank 1
answered on 21 Nov 2013, 01:01 PM
Here is code block for better understanding
<FormTemplate>
                       <telerik:RadTabStrip runat="server" ID="RadTabStrip1" Orientation="HorizontalTop"
                           SelectedIndex="0" MultiPageID="RadMultiPage1" CssClass="tabstrip" Skin="Default">
                           <Tabs>
                               <telerik:RadTab Text="Tab1">  </telerik:RadTab>
                             <telerik:RadTab Text="Tab2">  </telerik:RadTab>
                          </Tabs>
                       </telerik:RadTabStrip>
                       <telerik:RadMultiPage runat="server" ID="RadMultiPage1" SelectedIndex="0" CssClass="multiPage">
                           <telerik:RadPageView runat="server" ID="RadPageView2">
                               <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                   <ContentTemplate>
                                      some controls
                                 <asp:Button ID="btnUpdate" runat="server" Text='<%# IIf((TypeOf(Container) is                             GridEditFormInsertItem), "Insert", "Update") %>' CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update") %>'
                                                                   CausesValidation="False"></asp:Button>
                                                         </ContentTemplate>
                               </asp:UpdatePanel>
                           </telerik:RadPageView>
                         <telerik:RadPageView runat="server" ID="RadPageView2">
                               <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                   <ContentTemplate>
                                        <uc2:Campuses runat="server" ID="Campuses" />
                                   </ContentTemplate>
                               </asp:UpdatePanel>
                           </telerik:RadPageView>
                       </telerik:RadMultiPage>
                   </FormTemplate>
               </EditFormSettings>
0
Princy
Top achievements
Rank 2
answered on 22 Nov 2013, 09:50 AM
Hi Borislava,

Please modify your btnUpdate as follows ,it should fire the Update/Insert Command events. In UserControl also add this button code for Update/Insert.

ASPX:
<asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
</asp:Button>

Thanks,
Princy
0
Konstantin Dikov
Telerik team
answered on 22 Nov 2013, 10:02 AM
Hello Borislava,

For your convenience I have prepared a sample page with RadGrid that uses WebUserControl within the FormTemplate that works as expected on my end. 

As a side note, if you are ajaxifying your outer grid, please remove all UpdatePanels placed in the FormTemplate or at least the one place around the Button.

Hope that helps.


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.
Tags
Grid
Asked by
Borislava
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Borislava
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or