读书人

Repeater 怎么实现分页

发布时间: 2013-04-22 16:01:35 作者: rapoo

Repeater 如何实现分页
Bin 文件下已经引用AspNetPager.dll 事件里面的代码不会写。
部分代码如下:
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<%@ Page Title="大屏曲线图选择" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="LeftTop.aspx.cs" Inherits="_Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<style type="text/css">
ul{margin:0;padding:0}
</style>
</asp:Content>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<p>
 
<asp:Label ID="Label1" runat="server" Text="选择站点的名称:" ForeColor="Black"></asp:Label>
   
<asp:Label ID="lblchosename" runat="server" Width="230px"></asp:Label>
                                               
  
<asp:Label ID="Label3" runat="server" Text="顺序:" ForeColor="Black"></asp:Label>
   
<asp:TextBox ID="TextBoxTurn" runat="server" Width="50px"></asp:TextBox>
                   
<asp:Label ID="Label4" runat="server" Text="持续时间:" ForeColor="Black"></asp:Label>
  
<asp:TextBox ID="TextBoxTime" runat="server" Width="50px"></asp:TextBox>
                 
</p>
<p>
 <asp:Button ID="btnsearch" runat="server" Text="查找"
onclick="btnsearch_Click" />
 
<asp:TextBox ID="TextBox1" runat="server" Height="16px"></asp:TextBox>
                                                                                       


<asp:Label ID="Label5" runat="server" Text="趋势按照顺序轮换,每条趋势持续时间可以不同."></asp:Label>
      
<asp:Button ID="btnalter" runat="server" Text="修改" Width="50px" />
<asp:Repeater ID="Rptchose" runat="server"
ViewStateMode="Disabled">
<headertemplate>
<table style="width:55%;text-align:left" align=right class="sf">
<tr>
<th style="width:50%">站点名</th>
<th style="width:15%">顺序</th>
<th style="width:15%">持续时间</th>
</tr>
</headertemplate>
<itemtemplate>

<td><%#Eval("name1") %></td>
<td><%#Eval("b1") %></td>
<td><%#Eval("c1") %></td>
<td>


<asp:hiddenfield ID="abcd" runat="server" Value='<%#Eval("b1") %>' />

<a href="edit.aspx?<%#Eval("name1") %>">修改</a>
<a href="edit.aspx?<%#Eval("name1") %>">删除</a>

</td>
</tr>
</itemtemplate>
<footertemplate>
</table>
</footertemplate>
</asp:Repeater>
<webdiyer:aspnetpager id="AspNetPager1" runat="server"
onpagechanging="AspNetPager1_PageChanged" pagesize="20" ShowBoxThreshold="2" SubmitButtonText="跳转"
firstpagetext="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页"></webdiyer:aspnetpager>
</p>
<p>
<tr>
<asp:ListBox ID="lblnochose" runat="server" Height="400px" Width="326px"


AutoPostBack="True"
onselectedindexchanged="lblnochose_SelectedIndexChanged" >
</asp:ListBox>
<asp:Button ID="btnadd" runat="server" Text="添加>>"
onclick="btnadd_Click"
style="z-index: 1; left: 594px; top: 483px; position: absolute" />
</tr>
  
  
<tr>
<asp:Button ID="btndelete" runat="server" Text="<<删除"
onclick="btndelete_Click"
style="z-index: 1; left: 593px; top: 438px; position: absolute" />
</p>


</asp:Content>

后台代码:
/// <summary>
/// Summary description for Dbhelper
/// </summary>
public static class Dbconnect
{
public static string connstr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\大屏趋势支持库.mdb;Persist Security Info=False";

public static DataTable GetDataTable(string sqlstr)
{
//Datatable数据表的集合体-》存在内存中的表
DataTable dt = new DataTable();
//打开数据库链接
using (OleDbConnection conn = new OleDbConnection(connstr))
{
//取出数据库的工具
using (OleDbDataAdapter sda = new OleDbDataAdapter(sqlstr, conn))
{
conn.Open();
sda.Fill(dt);
}
}
return dt;
}

public static int ExecuteNonQuery(string sqlstr)
{
int res = -1;
using (OleDbConnection conn = new OleDbConnection(connstr))
{
using (OleDbCommand cmd = new OleDbCommand(sqlstr, conn))
{
conn.Open();


res = cmd.ExecuteNonQuery();
}
}
return res;
}
}

public void GetPageCount()
{
//????
}


protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
GetPageCount();
} .net c# repeater 分页
[解决办法]
http://www.webdiyer.com/AspNetPagerDocs/index.html
[解决办法]
楼上给的很详细
[解决办法]
我是说支持她的说法,给的参考资料还是很完整的啦~

现在问题解决了没有~
[解决办法]

引用:
没有。。。我很笨的。

别这么说啦,先到csdn的搜索频道去找找看,肯定有简单的解决办法的,先粘贴别人的代码实现功能,然后自己去研究下怎么实现~

读书人网 >C#

热点推荐