当allowPaging = true时gridview出错 - asp.net
我的 ASP.NET Web 表单中有 gridview。
我将我的数据库绑定到 gridview,如下所示:
SQL = "SELECT id,Fname,Lname FROM MEN";
dsView = new DataSet();
adp = new SqlDataAdapter(SQL, Conn);
adp.Fill(dsView, "MEN");
adp.Dispose();
GridView1.DataSource = dsView.Tables[0].DefaultView;
GridView1.DataBind();
我将其放入 gridview: allowPaging = true
它显示网格中的数据,但如果我按到第 2..3.. 页
,我得到这个错误:
The GridView 'GridView1' fired event PageIndexChanging which wasn't handled.
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: The GridView 'GridView1' fired event PageIndexChanging which wasn't handled.
提前致谢
i have gridview in my asp.net webform.
i bind my database to gridview like this:
SQL = "SELECT id,Fname,Lname FROM MEN";
dsView = new DataSet();
adp = new SqlDataAdapter(SQL, Conn);
adp.Fill(dsView, "MEN");
adp.Dispose();
GridView1.DataSource = dsView.Tables[0].DefaultView;
GridView1.DataBind();
and this i put in the gridview: allowPaging = true
its show the data in the grid, but if i press to page 2..3..
and i got this error:
The GridView 'GridView1' fired event PageIndexChanging which wasn't handled.
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: The GridView 'GridView1' fired event PageIndexChanging which wasn't handled.
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您必须处理 PageIndexChanging 事件,如果你点击设计器上的网格并查看事件,双击PageIndexChanging事件,如果你不需要取消或做任何特殊的事情,只需在处理程序中重新绑定数据即可
You have to handle the PageIndexChanging event, if you click the grid on the designer and look at the events, double click on the PageIndexChanging event, if you don't need to cancel or do anything special, just rebind the data in the handler
添加命名空间
您应该只使用 System.Collections.Generic
;并编写这段代码,只有
它 100% 有效,尝试一下......
You Should just add the namespace
using System.Collections.Generic;
and write this code only
it 100% works try it......
您必须为 PageIndexChanging 提供一个事件处理程序,这是您提供分页逻辑的地方。
You have to provide an event handler for PageIndexChanging, which is where you provide the paging logic.
在 GridView1_PageIndexChanging 事件中这样写:
然后再次绑定网格。
你的问题会解决。
write like this in
GridView1_PageIndexChanging
event:then again bind the grid.
ur prob will solve.