I have a webdatagrid 4 pages of 10 rows per page. How can I set the page index to page 2?
wgData.PageIndex = newPageIndex; // would be too easy right?
In this scenario, you can set the PageIndex property of the grid's Paging behavior in order to achieve your requirement.
This may be done via the designer as described at:
Alternatively, the following code may be used to set the page index from the code-behind:
WebDataGrid1.Behaviors.Paging.PageIndex = 2;
Ok, I set the behaviors to page 2 before databind but when I run this it displays page 1.
WebDataGrid1.Behaviors.Paging.PageIndex = 2; WebDataGrid1.DataBind();
I am attaching a small sample for this scenario using version 12.2.20122.2031 for you. If you are using a different version some sample code or markup illustrating the setup of the grid in your scenario would be greatly appreciated and will help us examine the scenario with identical configuration. Do not hesitate to contact me if you have any additional questions.
Please do not hesitate to contact me if you need any further assistance with this scenario.
When paging is enabled, do you have to manually set the new PageIndex?
Can you do this in the grid's PageIndexChanged event server side?
How do you get the new page index?