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

ItemInsert e.Canceled=true...what am I missing.

3 Answers 167 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 14 Sep 2010, 07:50 PM
I have a radgrid, bound to a datasource, and AllowAutomaticInserts=True

I have the following in the code behind:

Protected Sub RadGrid1_InsertCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.InsertCommand<br>
        If e.CommandName = RadGrid.InitInsertCommandName Then<br>
            e.Canceled = True<br>
        End If<br>
    End Sub


Here's the problem: I still get the edit form after hitting the InsertButton.

(NOTE: Of course this isn't what I want it to ultimately do...but I do need to supress the form for the time being, intending to call InsertItem() later...but I can't ever get to that point because the edit form can't be supressed!)

Thank you,

Steven

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 15 Sep 2010, 05:35 AM
Hello Steven,

I am not quite sure about your requirement. If you are performing the insert operation in code behind(manually), then set the AllowAutomaticInserts to false to close the inset/update form after insertion.

Could you please elaborate your requirement if it doesn't help?



Thanks,
Princy.
0
Steven
Top achievements
Rank 1
answered on 15 Sep 2010, 12:20 PM
Princy,  Thanks for your reply.

No, I want AutomaticInserts to continue working...The basic deal is, when they click on the "Add New Record" link in the CommandItem, instead of displaying the EditForm, I want to do some "other stuff."  I don't really want to get into that other stuff, because it will needlessly complicate this question (however I fear most are going to get too bogged down in the "why?" question)

So when they click the command button, and I get the "InitInsert" call through the commandItem, I want to cancel those edits, so I can do my other stuff.  I fully plan to call RadGrid1.MasterGridView.InsertItem() later down the line, but not right now.    Everything works great EXCEPT canceling the InitInsert seems to not work.

Does this make sense, or are we just too hung up in the "why do you want to do that?"   Understand the code snippet I posted had all my other code stripped out, I was only highlighting the one line of code that just wasn't working.

If I need to I'll generate a simple aspx file and paste it to isolate the exact problem...but at the end of the day it's very simple.

I have a Command Item.  Clicking the "Insert New Record" fires the ItemCommand event.   e.Canceled=true should CANCEL that ItemCommand.  It doesn't.   Why?

That's the entire problem.

Thank you,

Steven
0
Steven
Top achievements
Rank 1
answered on 15 Sep 2010, 01:51 PM
*sigh*

Amazing what  Night of sleep will do for you. 

I was handling the InsertCommand not the ItemCommand.  I saw that first thing this morning when I brought up my code...corrected my event handler, and everything works.

Thanks for your help. D'oh!!!!
Tags
Grid
Asked by
Steven
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Steven
Top achievements
Rank 1
Share this question
or