我把DataGrid的EnableViewState设置为false,但是这样分页无法正常使用 paging information (like CurrentPageIndex) is saved in the viewstate, consider to save them in the session variable or hidden control 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 consider to save them in the session variable or hidden control我也这么想过,可是我读取不到页码,怎么保存呢?我可以首先设置页码为0,但是跟着点了第5页,我无法取得5,怎么在session里设置为5呢?? http://dev.csdn.net/article/29/29802.shtm CMIC(大象) 这边文章也没有说enableviewstate设置为false后怎么读取页码啊 <asp:DataGrid id="DataGrid1" runat="server" AllowPaging="True" PageSize="3" EnableViewState="False"><PagerStyle Mode="NumericPages"></PagerStyle></asp:DataGrid>*.cs:private void Page_Load(object sender, System.EventArgs e){ if (!IsPostBack) { DataGrid1.DataSource = CreateDataSource(); DataGrid1.DataBind(); }}...private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e){ DataGrid1.CurrentPageIndex = e.NewPageIndex; DataGrid1.DataSource = CreateDataSource(); DataGrid1.DataBind();}把你的代码贴一下 acewang(龍芯*Inside!) 基本上我的代码差不多就那样,不过我是在<@ Page EnableViewState="false" %>这里设置了,DataGrid那里就用默认的(应该是true)但是很奇怪,我点击分页的时候,并没有调用DataGrid1_PageIndexChanged我在DataGrid1.CurrentPageIndex = e.NewPageIndex;这里设了断点的,但没有在这里停止 因为你把整个页面的ViewState禁用了,所以事件根本无法激发 是啊,后来我重写了DataGrid的OnLoad事件,调用PageIndexChanged事件,但是我无法取得页码,否则可以通过这种方式来实现 去除DataGrid中无用的ViewState数据的方法http://dev.csdn.net/develop/article/23/23670.shtm //重载该方法为DataGrid瘦身protected override object SaveViewState() { this.Controls[0].EnableViewState=false;return base.SaveViewState();} 中国通用表单生成的问题,请高手指点 已确认.net的一个BUG,希望寻求解决办法。。。 哪位仁兄对声音处理比较再行的,进来帮个忙!小弟百分相送! PROCESS运行指定程序的问题 sqlconnection佔用內存大小? C#调试中出现几个问题:未能找到类型或命名空间名称........ 此C语言中表达的意思的相当于C#中什么 微软自带的可查看c#代码的工具叫什么il?在什么地方可以找到? 文件流读取如何读取正确的中文字符 各位能谈谈学习c#的感受吗 做过表单的请进来,尤其是做过自定义的表单 请教关于Drawing的问题?
我也这么想过,可是我读取不到页码,怎么保存呢?我可以首先设置页码为0,但是跟着点了第5页,我无法取得5,怎么在session里设置为5呢??
这边文章也没有说enableviewstate设置为false后怎么读取页码啊
<PagerStyle Mode="NumericPages"></PagerStyle>
</asp:DataGrid>
*.cs:
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
DataGrid1.DataSource = CreateDataSource();
DataGrid1.DataBind();
}
}
...
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
DataGrid1.DataSource = CreateDataSource();
DataGrid1.DataBind();
}
把你的代码贴一下
基本上我的代码差不多就那样,不过我是在<@ Page EnableViewState="false" %>这里设置了,DataGrid那里就用默认的(应该是true)
但是很奇怪,我点击分页的时候,并没有调用DataGrid1_PageIndexChanged
我在DataGrid1.CurrentPageIndex = e.NewPageIndex;这里设了断点的,但没有在这里停止
http://dev.csdn.net/develop/article/23/23670.shtm
protected override object SaveViewState()
{
this.Controls[0].EnableViewState=false;
return base.SaveViewState();
}