Hi Brian,
In addition, are you using custom paging or the buildin paging support?
Have you set the AllowPaging property and AllowCustomPagi ng? If you're
using the buildin paging rather than custom paging, you need to set
AllowPaging as "true" and AllowCustomPagi ng 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>PagingGr id</title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.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:DataGrid id="dgPage" runat="server" AutoGenerateCol umns="False"
AllowPaging="Tr ue" PageSize="6"
EnableViewState ="False">
<Columns>
<asp:BoundColum n DataField="inde x"
HeaderText="Ind ex"></asp:BoundColumn >
<asp:BoundColum n DataField="name "
HeaderText="Nam e"></asp:BoundColumn >
<asp:BoundColum n DataField="pric e"
HeaderText="Pri ce"></asp:BoundColumn >
</Columns>
<PagerStyle PageButtonCount ="6" Mode="NumericPa ges"></PagerStyle>
</asp:DataGrid>
</td>
</tr>
</table>
</form>
</body>
</HTML>
==========code behind page class========== ===
public class PagingGrid : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid dgPage;
private void Page_Load(objec t sender, System.EventArg s 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)Ses sion["DATASOURCE "];
dgPage.DataSour ce = tb;
dgPage.DataBind ();
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.dgPage.Pag eIndexChanged += new
System.Web.UI.W ebControls.Data GridPageChanged EventHandler(th is.dgPage_PageI n
dexChanged);
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
private void dgPage_PageInde xChanged(object source,
System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
{
dgPage.CurrentP ageIndex = 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