Question

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.

Était-ce utile?

La solution

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.

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top