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

InsertCommand will not fire

3 Answers 143 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 30 Nov 2012, 04:13 PM
I'm trying to manually insert a row into an SQL table through the RadGrid's insert row function.  My problem is that the InsertCommand event will not fire.  Here's some code:

<telerik:RadGrid ID="grdDesc" runat="server" AutoGenerateColumns="false">
    <MasterTableView CommandItemDisplay="Top" EditMode="InPlace" DataKeyNames="Descrip"
      InsertItemPageIndexAction="ShowItemOnCurrentPage" ShowHeader="false">
        <Columns>
            <telerik:GridEditCommandColumn ButtonType="PushButton" UniqueName="Edit">
            </telerik:GridEditCommandColumn>
            <telerik:GridBoundColumn DataField="Descrip" UniqueName="Descrip">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
    <ClientSettings>
        <Scrolling UseStaticHeaders="true" AllowScroll="true" />
    </ClientSettings>
</telerik:RadGrid>
 
<telerik:RadInputManager runat="server" ID="RadInputManager1" Enabled="true">
    <telerik:TextBoxSetting BehaviorID="TextBoxSetting1">
    </telerik:TextBoxSetting>
</telerik:RadInputManager>


Visual Basic code:
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    ...
    Dim ctxSql As LINQtoSQLDataContext = New LINQtoSQLDataContext()
 
    If chkDesc.Checked = True Then
        grdDesc.Visible = True
        Dim descrips = From c In ctxSql.COMBOBOXes Where c.fieldname = "DESCRIP" Select New With {c.descrip}
 
        grdDesc.DataSource = descrips
        grdDesc.DataBind()
    Else
        grdDesc.Visible = False
    End If
    ...
End Sub
 
 
Protected Sub grdDesc_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles grdDesc.ItemCreated
    If TypeOf e.Item Is GridEditableItem AndAlso (e.Item.IsInEditMode) Then
        Dim editableItem As GridEditableItem = DirectCast(e.Item, GridEditableItem)
 
        Dim textBox = (DirectCast(editableItem.EditManager.GetColumnEditor("Descrip"), GridTextBoxColumnEditor)).TextBoxControl
 
        textBox.ID = "TextBox1"
        Dim inputSetting As InputSetting = RadInputManager1.GetSettingByBehaviorID("TextBoxSetting1")
        inputSetting.TargetControls.Add(New TargetInput(textBox.UniqueID, True))
        inputSetting.InitializeOnClient = True
        inputSetting.Validation.IsRequired = True
    End If
End Sub
 
Protected Sub grdDesc_InsertCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles grdDesc.InsertCommand
    Dim ctxSql As LINQtoSQLDataContext = New LINQtoSQLDataContext()
 
    Dim custFileID = ctxSql.CUSTFILEs.Where(Function(c) c.CUSTNO = cboCustNew.SelectedValue).Single.CUSTFILE
 
    Dim newComboBox As COMBOBOX = New COMBOBOX()
    newComboBox.custfile = custFileID
    newComboBox.department = -1
    newComboBox.fieldname = "DESCRIP"
    newComboBox.descrip = ""
 
    ctxSql.COMBOBOXes.InsertOnSubmit(newComboBox)
End Sub

I can tell you the ItemCreated event DOES fire and runs successfully.  I just don't understand why the InsertCommand event doesn't fire.  If anybody can tell me what I'm missing, it would be appreciated.

Thanks,
Patrick

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 01 Dec 2012, 04:45 AM
Hello,

i am not able to find any issue in your code, may be it is a view state issue so Can you please check below link?

http://www.telerik.com/community/forums/aspnet-ajax/grid/rad-grid-insert-command-not-firing.aspx#1406607

Thanks,
Jayesh Goyani
0
Patrick
Top achievements
Rank 1
answered on 03 Dec 2012, 04:01 PM
Thank you for your reply.

I have attempted to set EnableViewState on everything I could find.  I have verified that the grid and 5 levels of parents all have EnableViewState = true.  Unfortunately, the InsertCommand event still refuses to fire.

Is there something else I may be missing?

Thanks again,
Patrick
0
Jayesh Goyani
Top achievements
Rank 2
answered on 03 Dec 2012, 05:06 PM
Hello,

Can you please remove/comments all child grid and check ?

Let me know if its working or not.

If it still not working then can you please submit your project/Demo Project using SUPPORT TICKET.

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Patrick
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Patrick
Top achievements
Rank 1
Share this question
or