开发者

GridView Paging is not working?

I have a grid in that i am using this code on page init

        UpagedList = new PagedListAdapter<User>(UserListGridView);
        UpagedList.MaxRows = ConfigurationService.DefaultPageSize;
        UserListGridView.PageIndexChanged += delegat开发者_运维百科e
        {
            Presenter.FillDataOnDropDown();
        };
       UserListGridView.Sorting += new GridViewSortEventHandler(UserListGridView_Sorting);
       UserListGridView.Sorted += delegate {Presenter.SortChanged(); };

my grid code:

           <asp:GridView CssClass="Greed" ID="UserListGridView" runat="server" DataSourceID="ListUserDataSource"
              AutoGenerateColumns="false" EmptyDataText="No data found" DataKeyNames="Id" OnSorting="UserListGridView_Sorting" AllowSorting="True"
               PageSize="25" AllowPaging="True" GridLines="None" EnableViewState="false">
                   <Columns></Columns>
 </asp:GridView>

Paging is not working...? what else i need to do for paging.. when i am clicking on 2nd page page is not getting change but data is getting appended in grid


I think you missing the OnPageIndexChanging event in the gridview. Try adding this to your gridview OnPageIndexChanging="UserListGridViewIndexChanging" and in the backend code

protected void UserListGridViewIndexChanging(object sender, GridViewPageEventArgs e)
    {
        UserListGridView.PageIndex = e.NewPageIndex;
        Bind(); // you data bind code
    }

hope this helps


protected void UserListGridViewIndexChanging(object sender, GridViewPageEventArgs e)
{
    UserListGridView.PageIndex = e.NewPageIndex;
    UserListGridView.DataBind();
    Bind(); // you data bind code is here 
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜