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.
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
Hello mland,
try with this:
protected void Button1_Click1(object sender, EventArgs e) { WebHierarchicalDataGrid1.GridView.Behaviors.Paging.PageIndex = 2; }
Any thoughts on the code I posted
So here is my test project. On the button I have:
WebHierarchicalDataGrid1.Behaviors.Paging.PageIndex = 2;
I would have thought this would work but... Any suggestions?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Infragistics.Web.UI.GridControls;
using TotalCare.Enterprise.Common.ZeroClient;
namespace TotalCare.Enterprise.ZeroClient.RequestFacility.secure.Manager.Request
public class Parent
public Parent()
Description_l = string.Empty;
Id_l = 0;
public Parent(int id, string desc)
Description_l = desc;
Id_l = id;
private string Description_l;
public string Description
get { return Description_l; }
set { Description_l = value; }
private int Id_l;
public int ID
get { return Id_l; }
set { Id_l = value; }
public partial class _TestForm : TotalCare.Enterprise.ZeroClient.RequestFacility.common.tctBaseForm
protected override void OnInit(EventArgs e)
if (DesignMode)
return;
base.OnInit(e);
if (Session["Test"] == null)
Session["Test"] = CreateData();
WebHierarchicalDataGrid1.DataSource = Session["Test"];
protected void Page_Load(object sender, EventArgs e)
if (Page.IsPostBack == false)
WebHierarchicalDataGrid1.DataBind();
public List<Parent> CreateData()
List<Parent> xx = new List<Parent>();
for (int x = 0;
x < 90;
x++)
Parent curParent = new Parent(x, "Desc" + Convert.ToString(x));
xx.Add(curParent);
return xx;
protected void Button1_Click1(object sender, EventArgs e)
<body>
<form id="theForm" runat="server">
<asp:ScriptManager ID="ScriptManager2" EnablePartialRendering="true" runat="server">
</asp:ScriptManager>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Text="Button" />
<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" runat="server" AutoGenerateBands="false"
AutoGenerateColumns="False" DataKeyFields="ID" Width="300px" Height="350px" InitialDataBindDepth="0"
InitialExpandDepth="0">
<Columns>
<ig:BoundDataField DataFieldName="ID" Width="120px" Key="ID">
<Header Text="id_parent" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Description" Width="120px" Key="Description">
<Header Text="desc_parent" />
</Columns>
<Behaviors>
<ig:Paging PagerAppearance="Bottom" QuickPages="5" PageSize="15" Enabled="true">
</ig:Paging>
</Behaviors>
</ig:WebHierarchicalDataGrid>
</form>
</body>
you should be able to change page index on a button click. What is your datasource?