Help me stop RadGrid going to last page on Insert & keep dropdownlist data

3 posts, 0 answers
  1. Mike
    Mike avatar
    11 posts
    Member since:
    Jun 2012

    Posted 07 Jun 2012 Link to this post

    I am using a radgrid populated by a standard object datasource with a matching data entity. The grid populates fine and everything is operating fine except for when the Add New Record button is clicked the grid loses its current page and goes to the last page of the grid.

    I found a nifty way to stop that from happening along with preventing an edit and insert from occuring at the same time see code 1. This code block is firing on ItemCommand Insert Command.

    The problem is when I call e.Canceled it completely messes up my ItemDataBound function that is populating a drop down list used to pick a value on insert. How can I do both, keep the drop down list populating appropriately and keep my paging where it started when the AddNewRecord was clicked? I am open to a solution that doesn't use code block 1 as i think it may over complicate it but I need some help on how to tackle the problem. Any ideas?

    Code 1
    switch (e.CommandName.ToUpper()) {
        case "INITINSERT":
            //Ensure the grid doesn't jump to the last page
            e.Canceled = true;
            int pageIndex = e.Item.OwnerTableView.CurrentPageIndex;
            e.Item.OwnerTableView.CurrentPageIndex = pageIndex;
        case "EDIT":
            e.Item.OwnerTableView.IsItemInserted = false;
  2. Mike
    Mike avatar
    11 posts
    Member since:
    Jun 2012

    Posted 07 Jun 2012 Link to this post

    Murphy strikes again! Found the solution 2 seconds after posting.

    For those interested I had to change the line:



        e.Item.OwnerTableView.IsItemInserted = True;

    solution found here by Mr. Yavor:

    Thanks all!
  3. Greg
    Greg avatar
    7 posts
    Member since:
    Nov 2011

    Posted 03 Sep 2014 in reply to Mike Link to this post

    Just in case someone comes across this solution... I found a more recent post:
    <telerik:RadGrid ID="RadGrid1" runat="server">
        <MasterTableView InsertItemPageIndexAction="ShowItemOnCurrentPage">

Back to Top