Update/Insert/Delete with DataSourcePersistenceMode = NoPersistence

Thread is closed for posting
3 posts, 0 answers
  1. 63F75A2C-1F16-4AED-AFE8-B1BBD57646AD
    63F75A2C-1F16-4AED-AFE8-B1BBD57646AD avatar
    1572 posts
    Member since:
    Oct 2004

    Posted 30 Mar 2007 Link to this post

    Requirements

    RadGrid for ASP .NET version

    RadControls for ASP .NET AJAX version

    4.x and later


    2008.1.415 and later

    .NET version

    2.0 and later

    Visual Studio version

    2005 and later

    Programming language

    C#

    Browser support

    all supported by RadGrid for ASP .NET


    all browsers supported by RadControls for ASP .NET AJAX



    Note: With Telerik.Web.UI 2007.12.18+ or version 5.x of RadGrid/later you should set the EnableViewState property of the grid to false. DataSourcePersistenceMode is obsolete property and is excluded from the Prometheus version of RadGrid.

    PROJECT DESCRIPTION
    The project in this post demonstrates how to perform update/insert/delete when the EnableViewState property of the grid is set to false (light-weight grid viewstate persistence). In such mode the control event sequence is a bit different and the update/insert logic needs to be executed on NeedDataSource having some additional checks.

    Keep in mind that the mode with switched off viewstate has some additional limitations which are discussed in detail in these online resources:

    EnableViewState = false

    Optimizing viewstate usage
  2. 494010ED-DF0F-4C47-A15B-0A637AC8AE53
    494010ED-DF0F-4C47-A15B-0A637AC8AE53 avatar
    7 posts
    Member since:
    Jan 2005

    Posted 12 Oct 2009 Link to this post

    Hi,

    I run this demo UpdateInsertDeleteWithDisabledViewState_Web_UI.zip . When press cancel button on edtiform anyway insert record.

    What can i do?

    Regards.
  3. C7498A83-7E2E-418C-8791-93EF573A7569
    C7498A83-7E2E-418C-8791-93EF573A7569 avatar
    9934 posts
    Member since:
    Nov 2016

    Posted 15 Oct 2009 Link to this post

    Hello Francisso,

    Indeed you are right - in this case the edit/insert operation will be processed regardless whether you press the Cancel button or not due to the specific event sequence when the viewstate of RadGrid is disabled.

    The only option I can offer you is to remove the cancel button from the edit/insert form (thus disabling the cancel option) intercepting the ItemCreated event of the control, namely:

    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if(e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            e.Item.FindControl("CancelButton").Visible = false;
        }
    }

    I hope this is feasible for your situation.

    Best regards,
    Sebastian
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.