asp.net datalist控件分页显示
如题~~~asp.net datalist控件如何实现分页显示,每页显示3条数据 --------------------编程问答-------------------- 在分也绑定的代码里面写PagedDataSource pds=new PagedDataSource();
pds.AllowPaging = true;
pds.PageSize = 3;
--------------------编程问答-------------------- 前台HTML:
--------------------编程问答-------------------- 后台cs:
<div style="width: 310px">
共<a><%=totalPage %></a>页第<a class="number current"><%=currtPage%></a>页
<asp:LinkButton ID="lnkBtn_First" runat="server" Text="首页" OnClick="lnkBtn_First_Click" ForeColor="Lime"></asp:LinkButton>
<asp:LinkButton ID="lnkBtn_Prev" onmouseover="this.className='number current'" onmouseout="this.className='number'"
runat="server" Text="上页" CssClass="number" OnClick="lnkBtn_Prev_Click" ForeColor="Lime"></asp:LinkButton>
<asp:LinkButton ID="lnkBtn_Next" runat="server" Text="下页" OnClick="lnkBtn_Next_Click" ForeColor="Lime"></asp:LinkButton>
<asp:LinkButton ID="lnkBtn_Last" onmouseover="this.className='number current'" onmouseout="this.className='number'"
runat="server" CssClass="number" Text="尾页" OnClick="lnkBtn_Last_Click" ForeColor="Lime"></asp:LinkButton>
转<asp:DropDownList ID="ddl_Page" width="35px" runat="server"
AutoPostBack="True" OnSelectedIndexChanged="ddl_Page_SelectedIndexChanged">
</asp:DropDownList>页
</div>
分页绑定数据自己写,也为不知道你的数据库关系
--------------------编程问答-------------------- 试试AspNetPager: http://www.webdiyer.com/controls/aspnetpager --------------------编程问答-------------------- 对还不如aspnetpager灵活。。 --------------------编程问答-------------------- AspNetPager可以,也可以自定义分页的方式(例如:存储过程分页) --------------------编程问答--------------------
//第一页
protected void lnkBtn_First_Click(object sender, EventArgs e)
{
if (1 == currtPage)
{
return;
}
currtPage = 1;
BindDataList();
}
//最后一页
protected void lnkBtn_Last_Click(object sender, EventArgs e)
{
if (currtPage == totalPage)
{
return;
}
currtPage = totalPage;
BindDataList();
}
//下一页
protected void lnkBtn_Next_Click(object sender, EventArgs e)
{
if (currtPage + 1 > totalPage)
{
Response.Write("<script language=javascript>" + "alert(\"已经是最后一页\")" + "</script>");
return;
}
currtPage += 1;
BindDataList();
}
//上一页
protected void lnkBtn_Prev_Click(object sender, EventArgs e)
{
if (0 == currtPage - 1)
{
Response.Write("<script language=javascript>" + "alert(\"已经是最后一页\")" + "</script>");
return;
}
currtPage -= 1;
BindDataList();
}
//跳页
protected void ddl_Page_SelectedIndexChanged(object sender, EventArgs e)
{
currtPage = int.Parse(((DropDownList)sender).Text);
BindDataList();
}
支持 顶个
补充:.NET技术 , ASP.NET