So I have a grid with 10 pages. I am on page 5. I refresh the grid because my actions might have caused a number of rows to disappear. When I get the data and rebind, how do I go the the last page I had selected? I want the grid to be on page 5 after the refreshing of the data.
this.WebDataGridView.Behaviors.Paging.PageIndex I think this has what I am looking for.
this.WebDataGridView.Behaviors.Paging.PageIndex
I think this has what I am looking for.
Ah... Not as easy as it first looks. I looked at a couple of other post and can get the current page number. I do it with a hidden control on the client. Now I need to set the page index. I tried on a test button on the form that sets the DataSource and I call DataBind(). I then try to set the pagIndex
.Behaviors.Paging.PageIndex
this nas no effect. Where should I do this?
Hello mland,
you should be able to change page index on a button click. What is your datasource?
Any thoughts on the code I posted
So that works great on a button click. I tried to move it into Page_Load event. I am trying to set the page if it is a postback
if (!IsPostBack)
{
this.RequestGrid.DataBind();
WebHierarchicalDataGrid1.GridView.Behaviors.Paging.PageIndex = 2;
}
On my demo grid this worked great.
On my real grid I got an error, I turned off tracing and it worked. Seems a little odd.
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
[HttpException (0x80004005): Multiple controls with the same ID 'grdOffRequests:_ctl0:it1_0' were found. Trace requires that controls have unique IDs.] System.Web.TraceContext.AddNewControl(String id, String parentId, String type, Int32 viewStateSize, Int32 controlStateSize) +525 System.Web.UI.Control.BuildProfileTree(String parentId, Boolean calcViewState) +287 System.Web.UI.Control.BuildProfileTree(String parentId, Boolean calcViewState) +353 System.Web.UI.Control.BuildProfileTree(String parentId, Boolean calcViewState) +353 System.Web.UI.Control.BuildProfileTree(String parentId, Boolean calcViewState) +353 System.Web.UI.Control.BuildProfileTree(String parentId, Boolean calcViewState) +353 System.Web.UI.Control.BuildProfileTree(String parentId, Boolean calcViewState) +353 System.Web.UI.Page.BuildPageProfileTree(Boolean enableViewState) +39 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6585
try with this:
protected void Button1_Click1(object sender, EventArgs e) { WebHierarchicalDataGrid1.GridView.Behaviors.Paging.PageIndex = 2; }