Hi Brian,
In addition, are you using custom paging or the buildin paging support?
Have you set the AllowPaging property and AllowCustomPaging? If you're
using the buildin paging rather than custom paging, you need to set
AllowPaging as "true" and AllowCustomPaging as "false".
Here is a demo page I made using the buildin paging function and with the
EnableViewState as false:
You may have a try on your side to see whether it can provide any clues:
================aspx page==================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>PagingGrid</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="
http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="100%" align="center">
<tr>
<td><FONT face="ËÎÌå"></FONT></td>
</tr>
<tr>
<td>
<asp
ataGrid id="dgPage" runat="server" AutoGenerateColumns="False"
AllowPaging="True" PageSize="6"
EnableViewState="False">
<Columns>
<asp:BoundColumn DataField="index"
HeaderText="Index"></asp:BoundColumn>
<asp:BoundColumn DataField="name"
HeaderText="Name"></asp:BoundColumn>
<asp:BoundColumn DataField="price"
HeaderText="Price"></asp:BoundColumn>
</Columns>
<PagerStyle PageButtonCount="6" Mode="NumericPages"></PagerStyle>
</asp
ataGrid>
</td>
</tr>
</table>
</form>
</body>
</HTML>
==========code behind page class=============
public class PagingGrid : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid dgPage;
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
Session["DATASOURCE"] = GetDataSource();
}
Bind_Grid();
}
protected DataTable GetDataSource()
{
DataTable tb = new DataTable();
tb.Columns.Add("index");
tb.Columns.Add("name");
tb.Columns.Add("price",typeof(double));
DataRow dr = null;
bool[] flags = {true,false};
for(int i=1;i<=20;++i)
{
dr = tb.NewRow();
dr["index"] = i.ToString();
dr["name"] = "Name" + i.ToString();
dr["price"] = 3.434 * (i%3 +1);
tb.Rows.Add(dr);
}
return tb;
}
protected void Bind_Grid()
{
DataTable tb =(DataTable)Session["DATASOURCE"];
dgPage.DataSource = tb;
dgPage.DataBind();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dgPage.PageIndexChanged += new
System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.dgPage_PageIn
dexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void dgPage_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
dgPage.CurrentPageIndex = e.NewPageIndex;
Bind_Grid();
}
}
=========================================
Hope helps. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx