ItemInserting not firing

2 posts, 0 answers
  1. Richard
    Richard avatar
    28 posts
    Member since:
    Jun 2010

    Posted 24 Jan 2013 Link to this post


    I have a RadListView where I am dynamically creating the layout template and insert template at runtime.  Also just to let you know, I have the RadListView inside of a RadPanelBar whose ContentTemplate I am also creating at runtime.  This RandPanelBar is within a NestedGridView of a RadGrid.  All that is just an FYI as to the situation :)  I have all of this working, but I am having an issue with inserting a value into my RadListView.  I have a button that resides in the layouttemplate, where when I click it I am rebinding my listview and calling the ShowInsertItem command.  This is correctly showing my Inserttemplate items, where I have a radcombobox and radnumerictextbox. 

    At this point after the user fills these things in, I have a save button that is clicked.  This is where my problems lies. I need to be able to get the values of the radCombobox and radnumerictextbox from the edit template.  I tried to access them using FindControl within the save click, but that only finds controls in the layouttemplate.  So I wanted to implement the OnItemInserting event to be able to access the insert template.  At first, I just performed a PerformInsert() call.  But that gave me an error that the list view wasn't in insert mode.  To get around this, I had to call ShowInsertItem again.  By doing that, I can call PerformInsert.  But the event isn't firing, even if I reattach the event to the list view (just to be sure, since it is a dynamic control).  I tried changing my save button's CommandName to 'PerformInsert', but it seems to trigger an insert on the RadGrid and gives an error about it not being in insert mode.  Below is the code in my btnSave_Click event, could someone tell me what I'm doing wrong? Or is there a way within my btnSave_Click event to access the controls in the InsertTemplate?

    Thank you!
    rlv.DataSource = rlv.Page.Session[rlv.UniqueID + "_MyItems"]List<MyItem>;
    rlv.InsertItemTemplate = new CustomTemplate();
    rlv.PerformInsert(); // calls without error, but no event fired.
    rlv.InsertItemPosition = RadListViewInsertItemPosition.None;

  2. Angel Petrov
    Angel Petrov avatar
    1075 posts

    Posted 29 Jan 2013 Link to this post

    Hi Richard,

    You can access the controls in the InsertItemTemplate like shown in the code snippet below:
    By using this code you do not need to implement additional logic to obtain a reference to the controls in the insert template.

    All the best,
    Angel Petrov
    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.
Back to Top