Replies
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.
Multiple controls with the same ID 'grdOffRequests:_ctl0:it1_0' were
found. Trace requires that controls have unique IDs.
Description:
An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and
where it originated in the code.
Exception Details:
System.Web.HttpException: Multiple controls with the same ID
'grdOffRequests:_ctl0:it1_0' were found. Trace requires that controls have
unique IDs.
Source Error:
An unhandled exception was generated during the execution of the
|
Stack Trace:
|
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)
{
WebHierarchicalDataGrid1.Behaviors.Paging.PageIndex = 2;
}
}
}
<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" />
<Header Text="id_parent" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Description" Width="120px" Key="Description">
<Header Text="desc_parent" />
<Header Text="desc_parent" />
</ig:BoundDataField>
</Columns>
<Behaviors>
<ig:Paging PagerAppearance="Bottom" QuickPages="5" PageSize="15" Enabled="true">
</ig:Paging>
</Behaviors>
</ig:WebHierarchicalDataGrid>
</form>
</body>
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?