InsertItem go to LastPage, I like it go to firstpage

5 posts, 0 answers
  1. binbin
    binbin avatar
    26 posts
    Member since:
    Sep 2006

    Posted 14 Oct 2008 Link to this post

    As we know. when we click "add new record" on Grid

    Then we will find and InterForm will be open. and the page is go to last page.(see Pageing and records)

    but some times we need it go to first page. don't last page.
    Becase we hope datasource order by id Descending.

    Btw:I know how to set currentPage to fristpage after Insert
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 Oct 2008 Link to this post

    Hi,

    Try out the following code to show the insert form on the first page.
    cs:
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
        {  
          if (e.CommandName == RadGrid.InitInsertCommandName)   
            {   
                e.Canceled = true;   
                e.Item.OwnerTableView.IsItemInserted = true;   
                e.Item.OwnerTableView.Rebind();   
                return;   
            }   
        } 

    Thanks
    Princy
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Lucania
    Lucania  avatar
    65 posts
    Member since:
    May 2011

    Posted 26 Apr 2012 Link to this post

    Hi Princy,

    I am experiencing this issue, and I have the following code in my ItemCommand:
    case RadGrid.InitInsertCommandName:
        // cancel the default operation
        e.Canceled = true;
        //Prepare an IDictionary with the predefined values
        System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary();
        //set default checkbox value
        newValues["PlannerVisible"] = false;
        //Insert the item and rebind
        e.Item.OwnerTableView.InsertItem(newValues);
        break;
    I have tried adding the e.Item.OwnerTableView.IsItemInserted = true; as suggested, but it makes no difference - the grid still goes to the last page. Is there something else I need to do? My grid is sorted in descending order like binbin.

    Thanks

    ROSCO
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 Apr 2012 Link to this post

    Hell Ross,

    Please try setting InsertItemPageIndexAction property in MasterTableView.
    aspx:
    <MasterTableView  InsertItemPageIndexAction="ShowItemOnCurrentPage">

    Thanks,
    Princy.
  6. Lucania
    Lucania  avatar
    65 posts
    Member since:
    May 2011

    Posted 27 Apr 2012 Link to this post

    Thanks that works great!

    ROSCO
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017