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

Custom Pagine - CurrentPageIndex Always = 0

1 Answer 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
tbrown
Top achievements
Rank 1
tbrown asked on 22 Nov 2008, 11:03 AM
Hi all,

Just wondered if anybody could tell me why when doing custom paging the CurrentPageIndex of the grid is always equal to 0 no matter which page I click? Am I missing something really obvious?

I have my grid set up as follows and am only doing paging no sorting/grouping etc:

AllowPaging = true
AllowCustomPaging =true
PageSize=20
OnNeedDataSource=grid1_NeedDataSource

My code behind gets the name of a user entered into a search box txtName and then uses this as search criteria. If CurrentPageIndex is 0 I set it to 1 as that is what my sproc needs as a minimum startRowIndex. But whenever I debug and select a different page the grid1.MasterTableView.CurrentPageIndex property is always 0 and never changes.

protected void grid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
String name = txtName.Text.Trim();
Int32 totalRecords;
Int32 startRowIndex = grid1.MasterTableView.CurrentPageIndex == 0 ? 1 : grid1.MasterTableView.CurrentPageIndex * grid1.PageSize;
Int32 maximumRows = grid1.MasterTableView.PageSize;

if (name != String.Empty)
{
UserCollection users = UserMgr.GetByUserSearch(name, startRowIndex, maximumRows, out totalRecords);
grid1.VirtualItemCount = totalRecords;
grid1.DataSource = users;
}


Any help with this would be much appreciated as its starting to drive me a little insane.

Thanks

Tim

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 24 Nov 2008, 04:29 PM
Hi Tim,

Please try grid1.CurrentPageIndex instead grid1.MasterTableView.CurrentPageIndex and let me know about the result.

Sincerely yours,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
tbrown
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or