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

RadGrid with dynamic columns paging bug

2 Answers 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vincent
Top achievements
Rank 1
Vincent asked on 16 Jul 2013, 09:28 AM
Hello,

I am currently working on a RadGrid that has several dynamic columns, but I'm having some trouble with the paging. Paging seems to work fine, except when you attempt to navigate back to the first page. When you navigate back to the first page, the grid still shows the data of the last page you were on.

I have added a sample project and a screenshot of the problem that can be used to reproduce the problem. Follow these steps to reproduce the problem:
1. Navigate to page 3
2. Navigate to page 1
The grid now shows both pages as selected and is still showing the data of page 3.

public partial class Index : Page
    protected void Page_Init(object sender, EventArgs e) {
        this.CreateGrid();
    }
 
    private void CreateGrid() {
        RadGrid grid = new RadGrid();
        grid.ID = "gvBenchmark";
        grid.AutoGenerateColumns = false;
        grid.Skin = "Metro";
        grid.AllowSorting = true;
        grid.AllowPaging = true;
        grid.PageSize = 15;
        grid.SortingSettings.SortToolTip = String.Empty;
 
        GridBoundColumn idColumn = new GridBoundColumn();
        idColumn.HeaderText = "ID";
        idColumn.UniqueName = "ID";
        idColumn.DataField = "ID";
        grid.Columns.Add(idColumn);
 
        GridBoundColumn ageColumn = new GridBoundColumn();
        ageColumn.HeaderText = "Age";
        ageColumn.UniqueName = "Age";
        ageColumn.DataField = "Age";
        grid.Columns.Add(ageColumn);
 
        grid.DataSource = this.GetData();
        grid.DataBind();
 
        pnGrid.Controls.Add(grid);
    }
 
    private IList<Person> GetData() {
        IList<Person> persons = new List<Person>();
        for (int i = 0; i < 100; i++) {
            Person p = new Person();
            p.Age = i + 10;
            p.ID = i;
            persons.Add(p);
        }
 
        return persons;
    }
}
 
public class Person {
    public int Age { get; set; }
    public int ID { get; set; }
}

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 17 Jul 2013, 06:42 AM
Hi Vincent,

Please bind the data using NeedDataSource event of the radgrid.Please have a look at the following documentation.
Advanced Data-binding (using NeedDataSource event)

Let me know if any concern.

Thanks,
Shinu
0
Vincent
Top achievements
Rank 1
answered on 17 Jul 2013, 07:23 AM
Thank you, can't believe I missed that! Seems to work fine now.
Tags
Grid
Asked by
Vincent
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Vincent
Top achievements
Rank 1
Share this question
or