留言簿

我要留言
留言搜索

2007-01-29 11:52  lsfong

只有分页条,没有数据显示,请指教,谢谢!<br>这是存取数据存偖过程<br>create procedure dd <br>(@pagesize int,<br>@pageindex int)<br>as<br>set nocount on<br>begin<br>declare @indextable table(id int identity(1,1),nid int)<br>declare @PageLowerBound int<br>declare @PageUpperBound int<br>set @PageLowerBound=(@pageindex-1)*@pagesize<br>set @PageUpperBound=@PageLowerBound+@pagesize<br>set rowcount @PageUpperBound<br>insert into @indextable(nid) select id from kc  order by id desc<br>select * from kc O,@indextable t where O.id=t.nid<br>and t.id between @PageLowerBound+1 and @PageUpperBound order by t.id<br>end<br>set nocount off<br>-----------------<br>记录总数的存偖过程<br>CREATE PROCEDURE d<br>as<br>select count(id) from kc<br>GO<br>-------------------<br>page<br>&lt;asp:GridView ID=&quot;GridView1&quot; runat=&quot;server&quot;&gt;<br>        &lt;/asp:GridView&gt;<br>        &amp;nbsp;&lt;/div&gt;<br>        &lt;asp:SqlDataSource ID=&quot;SqlDataSource1&quot; runat=&quot;server&quot; ConnectionString=&quot;&lt;%$ ConnectionStrings:pubsConnectionString %&gt;&quot;<br>            SelectCommand=&quot;dd&quot; SelectCommandType=&quot;StoredProcedure&quot;&gt;<br>           &lt;SelectParameters&gt;<br>            &lt;asp:ControlParameter ControlID=&quot;AspNetPager1&quot; DefaultValue=&quot;10&quot; Name=&quot;pagesize&quot;<br>                PropertyName=&quot;PageSize&quot; Type=&quot;Int32&quot; /&gt;<br>            &lt;asp:ControlParameter ControlID=&quot;AspNetPager1&quot; DefaultValue=&quot;1&quot; Name=&quot;startIndex&quot;<br>                PropertyName=&quot;StartRecordIndex&quot; Type=&quot;Int32&quot; /&gt;<br>        &lt;/SelectParameters&gt;<br>        &lt;/asp:SqlDataSource&gt;<br>        &lt;webdiyer:aspnetpager id=&quot;AspNetPager1&quot; runat=&quot;server&quot;&gt;&lt;/webdiyer:aspnetpager&gt;<br>---------------<br>cs<br> protected void Page_Load(object sender, EventArgs e)<br>    {<br>        if (!IsPostBack)<br>        {<br>            int totalOrders = (int)SqlHelper.ExecuteScalar(CommandTy
回复:您好,您虽然创建了一个SqlDataSource,但根本没有用到,SqlDataSource本身是不显示任何东西的,您的意思应该是想让GridView来显示数据,但却没有把它的DataSourceID设为SqlDataSource的ID,所以不会有任何数据显示,要想显示SqlDataSource中的数据,应该设置GridView1的DataSourceID="SqlDataSource1"。谢谢!

2007-01-29 11:50  lsfong

这是存取数据存偖过程<br>&quot;create procedure dd <br>(@pagesize int,<br>@pageindex int)<br>as<br>set nocount on<br>begin<br>declare @indextable table(id int identity(1,1),nid int)<br>declare @PageLowerBound int<br>declare @PageUpperBound int<br>set @PageLowerBound=(@pageindex-1)*@pagesize<br>set @PageUpperBound=@PageLowerBound+@pagesize<br>set rowcount @PageUpperBound<br>insert into @indextable(nid) select id from kc  order by id desc<br>select * from kc O,@indextable t where O.id=t.nid<br>and t.id between @PageLowerBound+1 and @PageUpperBound order by t.id<br>end<br>set nocount off&quot;<br>-----------------<br>记录总数的存偖过程<br>&quot;CREATE PROCEDURE d<br>as<br>select count(id) from kc<br>GO&quot;<br>-------------------<br>page<br>&lt;asp:GridView ID=&quot;GridView1&quot; runat=&quot;server&quot;&gt;<br>        &lt;/asp:GridView&gt;<br>        &amp;nbsp;&lt;/div&gt;<br>        &lt;asp:SqlDataSource ID=&quot;SqlDataSource1&quot; runat=&quot;server&quot; ConnectionString=&quot;&lt;%$ ConnectionStrings:pubsConnectionString %&gt;&quot;<br>            SelectCommand=&quot;dd&quot; SelectCommandType=&quot;StoredProcedure&quot;&gt;<br>           &lt;SelectParameters&gt;<br>            &lt;asp:ControlParameter ControlID=&quot;AspNetPager1&quot; DefaultValue=&quot;10&quot; Name=&quot;pagesize&quot;<br>                PropertyName=&quot;PageSize&quot; Type=&quot;Int32&quot; /&gt;<br>            &lt;asp:ControlParameter ControlID=&quot;AspNetPager1&quot; DefaultValue=&quot;1&quot; Name=&quot;startIndex&quot;<br>                PropertyName=&quot;StartRecordIndex&quot; Type=&quot;Int32&quot; /&gt;<br>        &lt;/SelectParameters&gt;<br>        &lt;/asp:SqlDataSource&gt;<br>        &lt;webdiyer:aspnetpager id=&quot;AspNetPager1&quot; runat=&quot;server&quot;&gt;&lt;/webdiyer:aspnetpager&gt;<br>---------------<br>cs<br> &quot;protected void Page_Load(object sender, EventArgs e)<br>    {<br>        if (!IsPostBack)<br>        {<br>            int totalOrders = (int)SqlHelper.ExecuteScalar(Com

2007-01-29 10:59  pbzyy

我用Datalist分页,是不是必须先得到总页数!<br><br>这就意味这如果我们用多曾构架做的系统!<br>必须使用两个存储过程!<br>一个做为得到总的记录数!!<br><br>一个为翻页存储过程是吗??<br><br>是不是这样!?<br>有没有更好的办法!!!??
回复:是的,不过您也可以把两个存储过程合并为一个,用我的分页存储过程工具生成的分页存储过程默认就是获取记录总数和得到当前页的记录都在同一个过程中,当然您也可以分为两个过程,只是这样比较麻烦点而已。谢谢!

2007-01-28 16:09  riconyi

先感谢站长为我们提供了这个控件,我用的还是老版本的分页控件<br>以前没用存储过程分页,这次用了一下,带搜索条件的,出现如下错误:<br>查询后分页的数据全部可以出来,比如总共有多少页等,但是点击下一页或任意页时提示:<br>多次为 'A' 指定了列 'perid'。<br>这个查询我用了两个存储过程,一个是先显示全部的,这个点下一页没任何错误,一个是点搜索后按条件查询,就是查询的这个有问题<br><br>能否知我这种错误一般是什么地方要注意,再次感谢<br>如果有需要,我可以把代码全都贴出来
回复:查询后您需要用ViewState或Session等保存查询条件,否则分页后获取数据将变成获取的又是先前的所有记录而不是查询的记录了,这个可以参考一下示例项目中的搜索示例。至于您上面说的“多次为'A'指定了列'perid'”的错误,可能是您的数据绑定表达式的问题,您仔细检查一下。谢谢!

2007-01-28 10:23  xmc605

我的分页,有多少页他可以统计出来,但第一页和后面的页都是显示第一页的内容。我不太懂存储过程。麻烦你看看我的代码哪有问题。<br>===============================<br>private void Page_Load(object sender, System.EventArgs e)<br>		{<br>			// 在此处放置用户代码以初始化页面<br>			conn=new SqlConnection(ConfigurationSettings.AppSettings[&quot;Conn&quot;]);<br>			if(!IsPostBack)<br>			{<br>				cmd=new SqlCommand(&quot;select count(id) from job_qy where job_qyjob&gt;0 and zhongj=0&quot;,conn);<br>				conn.Open();<br>				pager.RecordCount=(int)cmd.ExecuteScalar();<br>				conn.Close();<br>				dd();<br>			}<br>		}<br>		void dd()<br>		{<br>			<br>			cmd=new SqlCommand(&quot;select * from job_qy where job_qyjob&gt;0 and zhongj=0 order by jobtime desc&quot;,conn);<br>			conn.Open();<br>			dlist.DataSource=cmd.ExecuteReader();<br>			dlist.DataBind();<br>			conn.Close();<br><br>			pager.CustomInfoText=&quot;加盟企业总数:&lt;font color=\&quot;blue\&quot;&gt;&lt;b&gt;&quot;+pager.RecordCount.ToString()+&quot;&lt;/b&gt;&lt;/font&gt;&quot;;<br>			pager.CustomInfoText+=&quot; 总页数:&lt;font color=\&quot;blue\&quot;&gt;&lt;b&gt;&quot;+pager.PageCount.ToString()+&quot;&lt;/b&gt;&lt;/font&gt;&quot;;<br>			pager.CustomInfoText+=&quot; 当前页:&lt;font color=\&quot;red\&quot;&gt;&lt;b&gt;&quot;+pager.CurrentPageIndex.ToString()+&quot;&lt;/b&gt;&lt;/font&gt;&quot;;<br>		}<br>		protected void ChangePage(object src,PageChangedEventArgs e)<br>		{<br>			pager.CurrentPageIndex=e.NewPageIndex;<br>			dd();<br>		}
回复:您选择并绑定到dlist数据绑定控件的是所有记录而不是当前页的记录,如果您不能在数据库层实现获取当前页的数据,那么就需要在程序中实现,比较简单的方法是使用PagedDataSource这个类,您可以参看一下示例项目中的示例,很多地方就是用这种方法实现分页的。谢谢!

2007-01-27 18:18  biqingwen

V6.0版本for vs2003,还会推出吗?我会一直等待的,呵呵.再问个问题,4.03版能不能在同一个页面放两个同属性同事件的分页控件,就是上面一个下面一个.谢谢.
回复:for 2003的正在测试以及编写示例和文档。可以在一个页面存在共享分页事件及属性的多个6.0.0以前版本的AspNetPager,只是在Url分页方式时每个分页控件都会引发一次PageChanged事件,这就等于多次重复绑定数据,所以如果一个页面上同时有多个共享分页事件处理程序的6.0.0以前版本的AspNetPager时,尽可能不要用Url分页方式,6.0.0版中通过使用CloneFrom这个属性避免出现这种问题。谢谢!

2007-01-27 10:13  lance

感谢作者提供了此控件,今天第一次使用,发现个问题.<br>我的数据是从xml文档取得的,xml的层次很多,我读到dataset以后,各个表是自动关链的.<br>我通过你的xml示例:<br>DataView dv = ds.Tables[&quot;PropertyLineItem&quot;].DefaultView;<br>            DataTable srcTbl = ds.Tables[&quot;PropertyLineItem&quot;].Clone();  //建立一个临时表,把一页内的记录放于此表<br>                for (int i = AspNetPager1.StartRecordIndex; i &lt;= AspNetPager1.EndRecordIndex; i++)<br>                {<br>                    srcTbl.ImportRow(dv[i - 1].Row);<br>                }              this.MyDataList.DataSource = srcTbl;               this.MyDataList.DataBind();<br>会出现丢失了表关链的情况,这样我在datalist里嵌套的控件就无法取得数据了.
回复:可能是因为克隆的srcTbl已不再属于该DataSet或不再保持表关链造成的,您可以试试重新把这个临时表和相关的表关链起来,用DataSet的Relations.Add()方法。谢谢!

2007-01-26 16:26  cardszq

吴大哥我上次那个问题还没解决.就是点分页控件没反映还老是第一页.我把.aspx文件和后台代码文件放出来帮我看下好吗.谢谢了.下载地址是http://www.hengxuan.net.cn/code.rar
回复:我仔细看了一下,可能原因是您使用url分页引起的,url分页时不需要在Page_Load中绑定数据,因为这样会绑定两次,去掉Page_Load中的绑定代码试试,因为我没办法调试,所以也没法排除是其它原因引起的,如果按上面的办法去掉Page_Load中的绑定代码还不行,您可以试试用默认的PostBack分页方式看能否正确分页。谢谢!

2007-01-26 16:14  zhqs1000

还有一个问题,我用的是sql server2000,你能不能发一份以前用vs2003写的那个分页事例,我需要是条件查询。zhqs1000@163.com
回复:您好,下载页面的4.3.3版中就有搜索示例,如果您不想安装,可以下载免安装版,解压后samples文件夹下的search.aspx就是查询示例。谢谢!

2007-01-26 16:13  zhqs1000

2007-1-25 16:12:57 zhqs1000<br>你好,我使用了你的分页控件,我有6万多条记录,但我分页到3000多条的时候,就不显示数据了,只是显示页码。<br>回复:您好,出现这样的问题的最可能原因是您获取数据的分页存储过程有问题,或者返回的要分页的记录总数大于实际的记录总数,请检查您获取数据和分页记录总数的代码。谢谢!<br><br>我检查了一下<br>CREATE procedure test <br>(@pagesize int,<br>@pageindex int,<br>@docount bit)<br>as<br>set nocount on<br>if(@docount=1)<br>select count(id) from v_forenotice<br>else<br>begin<br>declare @indextable table(id int identity(1,1),nid int)<br>declare @PageLowerBound int<br>declare @PageUpperBound int<br>set @PageLowerBound=(@pageindex-1)*@pagesize<br>set @PageUpperBound=@PageLowerBound+@pagesize<br>set rowcount @PageUpperBound<br>insert into @indextable(nid) select id from v_forenotice order by id asc<br>select O.id,O.title ,t.id as tid,O.username,O.Properties,O.tvname,O.channelname,O.hits,O.othername,O.staticurl, case isnull(staticurl,null) when null then '未' else '已' end as jt,O.keywords from v_forenotice O,@indextable t where O.id=t.nid<br>and t.id between @PageLowerBound+1 and @PageUpperBound order by t.id<br>end<br>set nocount off<br>GO<br>这是存储过程<br>已经搞好了,谢谢,真的很快
回复:好了就好:)谢谢及时回复!
;