| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1709 人关注过本帖
标题:笨笨姐用你教的DataGrid分页法出现问题了
取消只看楼主 加入收藏
shayatou
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-4-26
收藏
 问题点数:0 回复次数:1 
笨笨姐用你教的DataGrid分页法出现问题了

下面是错误代码,请笨笨姐看看,谢谢。

当 AllowPaging 设置为真并且选定的数据源不实现 ICollection 时,AllowCustomPaging 必须为真,并且 ID 为 DataGrid1 的 DataGrid 必须设置 VirtualItemCount。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Web.HttpException: 当 AllowPaging 设置为真并且选定的数据源不实现 ICollection 时,AllowCustomPaging 必须为真,并且 ID 为 DataGrid1 的 DataGrid 必须设置 VirtualItemCount。

源错误:


行 35: this.DataGrid1.DataKeyField="id";
行 36: this.DataGrid1.DataSource=dr;
行 37: this.DataGrid1.DataBind();
行 38: }
行 39:

源文件: c:\inetpub\wwwroot\mybook\admin_manage.aspx.cs 行: 37

堆栈跟踪:


[HttpException (0x80004005): 当 AllowPaging 设置为真并且选定的数据源不实现 ICollection 时,AllowCustomPaging 必须为真,并且 ID 为 DataGrid1 的 DataGrid 必须设置 VirtualItemCount。]
System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean useDataSource)
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e)
System.Web.UI.WebControls.BaseDataList.DataBind()
Mybook.manage.BindToDataGrid() in c:\inetpub\wwwroot\mybook\admin_manage.aspx.cs:37
Mybook.manage.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\mybook\admin_manage.aspx.cs:25
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

搜索更多相关主题的帖子: DataGrid 堆栈 数据源 AllowPaging ICollection 
2006-05-05 16:31
shayatou
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-4-26
收藏
得分:0 


private void Page_Load(object sender, System.EventArgs e)

{

if (!this.IsPostBack)

{

DataGridBind();

}

}

private void DataGridBind()

{

OleDbConnenction con = new OleDbConnenction(连接access数据库串);
con.open();
OleDbCommand cmd=new OleDbCommand("select * from test",con);
OleDbDataReader dr=cmd.excuder......
this..datasource=dr;
this.DataGrid1.databind();

}
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)

{

this.DataGrid1.CurrentPageIndex = e.NewPageIndex;

DataGridBind();

}

2006-05-05 16:39
快速回复:笨笨姐用你教的DataGrid分页法出现问题了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011820 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved