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

InsertCommand event not firing

2 Answers 236 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 01 Feb 2011, 09:21 PM
I have a RadGrid using the standard command, "Add New Record". Clicking on this does post back (InitInsert) and places the first row (I'm using InPlace editing) into edit mode as well as performing the validations for fields in the row (using standrd Required Field Validators), but clicking on the Insert link does nothing, no postback at all!

The Edit/Update/Cancel (through an EditCommand column) works fine for all of these functions and I'm trying to capture the Insert (i.e. PerformInsert or InsertCommand) event as it bubbles to the InsertCommand event handler so I can pull values from the form and update the data repository.

Here's the grid definition (I've omitted the column definitions for brevity):

<telerik:radgrid id="RadGrid_StaffBreakout" runat="server" 
    autogeneratecolumns="False" allowsorting="True" gridlines="None" insertitempageindexaction="ShowItemOnFirstPage"
    width="400px" allowpaging="True" skin="Windows7" horizontalalign="Center">
    <ItemStyle HorizontalAlign="Center" BorderWidth="0px" />
    <MasterTableView HorizontalAlign="Center" GridLines="None" EditMode="InPlace" CommandItemDisplay="TopAndBottom">            
        <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
        <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" 
            Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Center" 
            Wrap="True" VerticalAlign="Middle" />
        <AlternatingItemStyle Font-Bold="False" Font-Italic="False" 
            Font-Overline="False" Font-Strikeout="False" Font-Underline="False" 
            HorizontalAlign="Center" Wrap="True" VerticalAlign="Middle" />
        <EditItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" 
            Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Center" 
            Wrap="True" VerticalAlign="Middle" />
        <PagerStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" 
            Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Center" 
            VerticalAlign="Middle" Wrap="True" />
        <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" 
            Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Center" 
            Wrap="True" VerticalAlign="Bottom" />
    </MasterTableView>
    <HeaderStyle BorderStyle="None" />
</telerik:RadGrid>

When I hover over the Insert link, the href for it is set to, "javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("StaffBreakout$RadGrid_StaffBreakout$ctl00$ctl02$ctl03$PerformInsertButton", "", true, "", "", false, true))". I tried searching in the source of the page for this ID and didn't find it, but I'm not sure how to get this to be inserted into the page (or how I managed to omitted this).

I tried setting breakpoints in both PageLoad and InsertCommand event handlers, but neither gets called after the form is initially set up (i.e. InitInsert) - no PeformInsert/InsertCommand is ever being called.

All help appreciated!

Jon

2 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 03 Feb 2011, 02:13 PM
Hi Jon,

I suspect the problem might be related to the Required Field validators in the grid. You can check this online demo for more detailed information on how the validation should be configured. Basically you should use the properties in the ValidationSettings section of the grid.

Kind regards,
Marin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Jon
Top achievements
Rank 1
answered on 09 Feb 2011, 08:02 PM

Marin,

Thanks for your reply. I ended up catching the ItemCommand event server-side and this seems to be working fine.

Protected Sub RadGrid_StaffBreakout_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid_StaffBreakout.ItemCommand
  
    If TypeOf e.Item Is GridDataInsertItem Then
        Dim editItem As GridEditableItem = DirectCast(e.Item, GridEditableItem)
  
        If e.CommandName = "Cancel" Then
            e.Canceled = True
        Else
            PerformEdit(editItem)
            If RadGrid_StaffBreakout.MasterTableView.IsItemInserted() Then
                e.Item.Edit = False
            End If
        End If
        e.Item.OwnerTableView.Rebind()
    End If
End Sub

Note: I did have to cancel the edit, since the grid was remaining in edit/insert mdoe after the insert completed>

Thanks,

Jon
Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Marin
Telerik team
Jon
Top achievements
Rank 1
Share this question
or