0

I get the paging to show when the RadGrid is shown, but when I try to click for the next page the RadGrid disappears.

Here are the following screenshots that might help with this problem

The asp page

This is where the RadGrid is initially loaded

This is the pageindexchanged

Please help with some guidance to help me resolve this issue.

Amarnath Balasubramanian
  • 9,300
  • 8
  • 34
  • 62
SpaceApple
  • 1,309
  • 1
  • 24
  • 46
  • you don't have to take screenshots of your code, for that propurse exists the code block in the editor, use it!!! – Rafael Oct 31 '12 at 14:14

2 Answers2

3

You don't need the PageIndexChanged event, since you're not doing any funky stuff there.

As Ali Issa said, you should use the OnNeedDataSource event, which is gonna be called when you fetch for next page.

So follow these steps:

  1. Remove the following code:

    protected void RadGrid1_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e)
    {
        this.GridView1.CurrentPageIndex = e.NewPageIndex;
        GridView1.DataSource = tbl;
        GridView1.DataBind();
    }
    

    in your aspx file:

    OnPageIndexChanged="RadGrid1_PageIndexChanged"

  2. And add the following code:

    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        GridView1.DataSource = tbl;
    }
    

    in your aspx file:

    OnNeedDataSource="RadGrid1_NeedDataSource"

One last thing: Don't forget your tbl variable must be re-assigned on every server call (unless tbl is a Session variable). So, make sure tbl is at least defined in your Page_Load but the best would be to replace tbl to some Database call.

Francis P
  • 13,377
  • 3
  • 27
  • 51
1

Try to bind the grid on NeedDataSource event, then on pageindexchanged call Gridview1.Rebind();

Alex
  • 5,971
  • 11
  • 42
  • 80
  • I am not sure what you mean exactly. But in the PageIndexChanged call I have added the GridView1.Rebind() and it still does not work – SpaceApple Oct 31 '12 at 12:28
  • when u say the RadGrid disappears you mean it is disappeared completely or it is shown with no records – Alex Oct 31 '12 at 12:43
  • Also have this problem. In my case it is fully disappearing... – SiL3NC3 Jul 07 '20 at 09:48