CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  ASP.NET

::::分页错误::::,请求解决。

楼主ciscopaper(风筝(ciscopaper.cnedu.com.cn))2003-12-04 15:46:48 在 .NET技术 / ASP.NET 提问

错误提示如下:  
   
  当   AllowPaging   设置为真并且选定的数据源不实现   ICollection   时,AllowCustomPaging   必须为真,并且   ID   为   dgBrand   的   DataGrid   必须设置   VirtualItemCount。  
   
  我用的是自带的分页。 问题点数:30、回复次数:8Top

1 楼acewang(龍芯*Inside!)回复于 2003-12-04 15:51:10 得分 25

你是不是用DataReader填充的数据?Top

2 楼ciscopaper(风筝(ciscopaper.cnedu.com.cn))回复于 2003-12-04 15:57:27 得分 0

用的是数据集DataSetTop

3 楼acewang(龍芯*Inside!)回复于 2003-12-04 16:02:00 得分 0

贴你填充数据的代码,我不想一句一句的猜谜Top

4 楼ciscopaper(风筝(ciscopaper.cnedu.com.cn))回复于 2003-12-04 16:03:06 得分 0

实在是找不出错误所在。  
  会不会与目录层次有关,我建的是一个NEWS项目,现在的分页文件是在  
  news/info/fashion/下的。  
   
  可能吗?Top

5 楼einsteincao(至尊宝!pig难过恐龙关)回复于 2003-12-04 16:04:40 得分 5

<%@   Import   Namespace="System.Data"   %>  
  <%@   Import   Namespace="System.Data.SQL"   %>  
   
   
  <script   language="VB"   runat="server">  
   
  Sub   Page_Load(sender   As   Object,   e   As   EventArgs)    
          BindGrid  
  End   Sub  
   
  Sub   MyDataGrid_Page(sender   As   Object,   e   As   DataGridPageChangedEventArgs)    
          startIndex   =   MyDataGrid.CurrentPageIndex   *   MyDataGrid.PageSize  
          BindGrid  
          ShowStats  
  End   Sub  
   
  Sub   BindGrid()  
   
  Dim   DS   As   DataSet  
  Dim   MyConnection   As   SQLConnection  
  Dim   MyCommand   As   SQLDataSetCommand  
  conn_str="server=localhost;uid=sa;pwd=;database=pubs"    
  '连接字符  
  db_sql="select   *   from   tablename"  
  'sql查询  
   
  MyConnection   =   New   SQLConnection(conn_str)  
  MyCommand   =   New   SQLDataSetCommand(db_sql,   MyConnection)  
   
  DS   =   new   DataSet()  
  MyCommand.FillDataSet(ds,   "tablename")  
   
  MyDataGrid.DataSource=ds.Tables("tablename").DefaultView  
  MyDataGrid.DataBind()  
   
   
  ShowStats  
  End   Sub  
   
  Sub   PagerButtonClick(sender   As   Object,   e   As   EventArgs)  
  'used   by   external   paging   UI  
  Dim   arg   As   String   =   sender.CommandArgument  
   
  Select   arg  
          Case   "next":  
                  If   (MyDataGrid.CurrentPageIndex   <   (MyDataGrid.PageCount   -   1))   Then  
                          MyDataGrid.CurrentPageIndex   +=   1  
                  End   If    
  Case   "prev":  
                  If   (MyDataGrid.CurrentPageIndex   >   0)   Then  
                          MyDataGrid.CurrentPageIndex   -=   1  
                  End   If    
  Case   "last":  
                  MyDataGrid.CurrentPageIndex   =   (MyDataGrid.PageCount   -   1)  
  Case   Else:  
          'page   number  
                  MyDataGrid.CurrentPageIndex   =   arg.ToInt32()  
  End   Select  
   
  BindGrid  
  ShowStats  
  End   Sub  
   
  Sub   ShowStats()  
  lblCurrentIndex.Text   =   "CurrentPageIndex   is   "   &   MyDataGrid.CurrentPageIndex  
  lblPageCount.Text   =   "PageCount   is   "   &   MyDataGrid.PageCount  
  End   Sub  
  </script>  
   
   
   
          <form   runat="server">  
           
  <ASP:DataGrid   id="MyDataGrid"   runat="server"  
  AllowPaging="True"  
  PageSize="5"  
  PageCount="1"  
  PagerStyle-Mode="NumericPages"  
  PagerStyle-HorizontalAlign="Right"  
  OnPageIndexChanged="MyDataGrid_Page"  
  BorderColor="black"  
  BorderWidth="1"  
  GridLines="Both"  
  CellPadding="3"  
  CellSpacing="0"  
  Font-Name="Verdana"  
  Font-Size="8pt"  
  HeaderStyle-BackColor="#aaaadd"  
  AlternatingItemStyle-BackColor="#eeeeee"  
  />  
          </form>  
   
  <p>  
   
  <asp:LinkButton   id="btnFirst"   runat="server"  
  Text="Go   to   the   first   page"  
  CommandArgument="0"  
  ForeColor="navy"  
  Font-Name="verdana"   Font-size="8pt"  
  OnClick="PagerButtonClick"  
  />  
     
  <asp:LinkButton   id="btnPrev"   runat="server"  
  Text="Previous   page"  
  CommandArgument="prev"  
  ForeColor="navy"  
  Font-Name="verdana"   Font-size="8pt"  
  OnClick="PagerButtonClick"  
  />  
     
  <asp:LinkButton   id="btnNext"   runat="server"  
  Text="Next   page"  
  CommandArgument="next"  
  ForeColor="navy"  
  Font-Name="verdana"   Font-size="8pt"  
  OnClick="PagerButtonClick"  
  />  
     
  <asp:LinkButton   id="btnLast"   runat="server"  
  Text="Go   to   the   last   page"  
  CommandArgument="last"  
  ForeColor="navy"  
  Font-Name="verdana"   Font-size="8pt"  
  OnClick="PagerButtonClick"  
  />  
   
  <p>  
   
  <table   bgcolor="#eeeeee"   cellpadding="6"><tr><td   nowrap><font   face="Verdana"   size="-2">  
   
  <asp:Label   id="lblCurrentIndex"   runat="server"   />  
   
  <asp:Label   id="lblPageCount"   runat="server"   />  
  Top

6 楼sjzwinfor(蜘蛛侠)回复于 2003-12-04 16:04:50 得分 0

源码Top

7 楼ciscopaper(风筝(ciscopaper.cnedu.com.cn))回复于 2003-12-04 16:08:15 得分 0

用的是一个类SqlConn;  
  SqlConn   DBconn   =   new   SqlConn();  
  DBconn.connstr   ="poroduct";     //product   为数据库名  
  dgBrand.DataSource   =   DBconn.Exec_dt("select   *   from   brand");  
  dgBrand.DataBind();  
   
  下面为类的方法:  
  public   DataTable   Exec_dt(string   Sql)    
  {//返回一个数据表格dt       ::主要用于绑定数据::  
  SqlConnection   Conn   =   new   SqlConnection(Sqlconnstr);  
  DataSet   ds   =   new   DataSet();  
  SqlDataAdapter   dap   =   new   SqlDataAdapter(Sql,Conn);  
  dap.Fill(ds);  
  dap.Dispose();  
  Conn.Close();  
  Conn.Dispose();  
  return   ds.Tables[0];  
  }Top

8 楼acewang(龍芯*Inside!)回复于 2003-12-04 16:25:51 得分 0

你是不是将DataTable直接绑定到DataSet上了?  
  DataGrid1.DataSource=DataTable1.DefaultView;  
  DataGrid1.DataBind()Top

相关问题

  • 分页错误???
  • 下面的分页有错误,有分!
  • 为什么会出现"分页发生错误"的错误?
  • ASSERT 错误,请求解答
  • 关于分页显示出现连接超时错误?
  • 写分页时出现错误,高手请教
  • 为什么asp分页显示ADODB.Field (0x80020009)错误
  • 一个分页的错误,请大家帮忙看看呀
  • DataGrid分页问题,莫名其妙的错误,头大,救命!!
  • 为何会有这个错误?datagrid的分页

关键词

  • 数据
  • ds
  • datagrid
  • 分页
  • dgbrand
  • dap
  • sqlconn
  • dbconn
  • datatable
  • conn

得分解答快速导航

  • 帖主:ciscopaper
  • acewang
  • einsteincao

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo