关于多张图片的显示问题(高分求助) 使用DataList来分页可以自由的排版 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 使用DataList来分页,可以得到你所需要排版的效果。一行5张图片及他们的评论,一页5行,非常简单。 DataList 好象没有分页的属性呀 datalist没有自动分页的功能呀 对,没有错.DataList是没有自动分页的功能,要自己写分页的程序.请到www.aspcn.com 查看DataList控件也玩分页 的文章, re:回复人: meetweb(niky) DataList控件也玩分页这篇文章被删了,找不到了有好的方法吗?问题解决了,一定给高分 你可以到www.chinaasp.com论坛里ASP-->DOTNET的精华区了可以找到关于DataList控件也玩分页的文章。。应该没有问题。。 不过这篇文章有一个bug,你慢慢就会体会到。不过很容易就可以修改 他的分页的时候有一点点bug,,,,,,,<% @ Page Language="C#" %> <% @ Import Namespace="System.Data" %> <% @ Import Namespace="System.Data.OleDb" %> <Script Language="C#" Runat="Server"> /* Create By 飞刀 http://www.aspcn.com 2001-7-25 01:44 Support .Net Framework Beta 2 */ OleDbConnection MyConn; int PageSize,RecordCount,PageCount,CurrentPage; public void Page_Load(Object src,EventArgs e) { //设定PageSize PageSize = 10; //连接语句 string MyConnString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+Server.MapPath(".")+"..\\DataBase\\db1.mdb;"; MyConn = new OleDbConnection(MyConnString); MyConn.Open(); //第一次请求执行 if(!Page.IsPostBack) { ListBind(); CurrentPage = 0; ViewState["PageIndex"] = 0; //计算总共有多少记录 RecordCount = CalculateRecord(); lblRecordCount.Text = RecordCount.ToString(); //计算总共有多少页 PageCount = RecordCount/PageSize; lblPageCount.Text = PageCount.ToString(); ViewState["PageCount"] = PageCount; } } //计算总共有多少条记录 public int CalculateRecord() { int intCount; string strCount = "select count(*) as co from Score"; OleDbCommand MyComm = new OleDbCommand(strCount,MyConn); OleDbDataReader dr = MyComm.ExecuteReader(); if(dr.Read()) { intCount = Int32.Parse(dr["co"].ToString()); } else { intCount = 0; } dr.Close(); return intCount; } ICollection CreateSource() { int StartIndex; //设定导入的起终地址 StartIndex = CurrentPage*PageSize; string strSel = "select * from Score"; DataSet ds = new DataSet(); OleDbDataAdapter MyAdapter = new OleDbDataAdapter(strSel,MyConn); MyAdapter.Fill(ds,StartIndex,PageSize,"Score"); return ds.Tables["Score"].DefaultView; } public void ListBind() { score.DataSource = CreateSource(); score.DataBind(); lbnNextPage.Enabled = true; lbnPrevPage.Enabled = true; if(CurrentPage==(PageCount-1)) lbnNextPage.Enabled = false; if(CurrentPage==0) lbnPrevPage.Enabled = false; lblCurrentPage.Text = (CurrentPage+1).ToString(); } public void Page_OnClick(Object sender,CommandEventArgs e) { CurrentPage = (int)ViewState["PageIndex"]; PageCount = (int)ViewState["PageCount"]; string cmd = e.CommandName; //判断cmd,以判定翻页方向 switch(cmd) { case "next": if(CurrentPage<(PageCount-1)) CurrentPage++; break; case "prev": if(CurrentPage>0) CurrentPage--; break; } ViewState["PageIndex"] = CurrentPage; ListBind(); } </script> <html> <head> <title></title> </head> <body> <form runat="server"> 共有<asp:Label id="lblRecordCount" ForeColor="red" runat="server" />条记录 当前为<asp:Label id="lblCurrentPage" ForeColor="red" runat="server" />/<asp:Label id="lblPageCount" ForeColor="red" runat="server" />页 <asp:DataList id="score" runat="server" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="Gainsboro" EditItemStyle-BackColor="yellow" > <ItemTemplate> 姓名:<%# DataBinder.Eval(Container.DataItem,"Name") %> <asp:LinkButton id="btnSelect" Text="编辑" CommandName="edit" runat="server" /> </ItemTemplate> </asp:DataList> <asp:LinkButton id="lbnPrevPage" Text="上一页" CommandName="prev" OnCommand="Page_OnClick" runat="server" /> <asp:LinkButton id="lbnNextPage" Text="下一页" CommandName="next" OnCommand="Page_OnClick" runat="server" /> </form> </body> </html> ibatis“/”应用程序中的服务器错误。 一个正规的意思? 自定义控件 动态修改header 上传文件的页面时常出现404Error 跪求asp.net四级下拉框无刷新代码,数据库是SQL,急啊~!!!! 关于读取xml文件的问题???(在线等!!!) 关于文件上传的问题 最常用的功能!!! 一套全新的VS .Net 2003 Professional(尚未开封)想出售,谁要? 在ASP.Net中怎么用PerformanceCounter阿 请教TextBox DropDownList问题!急急 怎样往Panel中加入其他控件?
请到www.aspcn.com 查看
DataList控件也玩分页 的文章,
DataList控件也玩分页
这篇文章被删了,找不到了
有好的方法吗?问题解决了,一定给高分
的精华区了可以找到关于DataList控件也玩分页的文章。。
应该没有问题。。
<% @ Page Language="C#" %>
<% @ Import Namespace="System.Data" %>
<% @ Import Namespace="System.Data.OleDb" %>
<Script Language="C#" Runat="Server">
/*
Create By 飞刀
http://www.aspcn.com
2001-7-25 01:44 Support .Net Framework Beta 2
*/
OleDbConnection MyConn;
int PageSize,RecordCount,PageCount,CurrentPage;
public void Page_Load(Object src,EventArgs e)
{
//设定PageSize
PageSize = 10; //连接语句
string MyConnString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+Server.MapPath(".")+"..\\DataBase\\db1.mdb;";
MyConn = new OleDbConnection(MyConnString);
MyConn.Open(); //第一次请求执行
if(!Page.IsPostBack)
{
ListBind();
CurrentPage = 0;
ViewState["PageIndex"] = 0; //计算总共有多少记录
RecordCount = CalculateRecord();
lblRecordCount.Text = RecordCount.ToString(); //计算总共有多少页
PageCount = RecordCount/PageSize;
lblPageCount.Text = PageCount.ToString();
ViewState["PageCount"] = PageCount;
}
}
//计算总共有多少条记录
public int CalculateRecord()
{
int intCount;
string strCount = "select count(*) as co from Score";
OleDbCommand MyComm = new OleDbCommand(strCount,MyConn);
OleDbDataReader dr = MyComm.ExecuteReader();
if(dr.Read())
{
intCount = Int32.Parse(dr["co"].ToString());
}
else
{
intCount = 0;
}
dr.Close();
return intCount;
} ICollection CreateSource()
{ int StartIndex; //设定导入的起终地址
StartIndex = CurrentPage*PageSize;
string strSel = "select * from Score";
DataSet ds = new DataSet(); OleDbDataAdapter MyAdapter = new OleDbDataAdapter(strSel,MyConn);
MyAdapter.Fill(ds,StartIndex,PageSize,"Score"); return ds.Tables["Score"].DefaultView;
}
public void ListBind()
{
score.DataSource = CreateSource();
score.DataBind(); lbnNextPage.Enabled = true;
lbnPrevPage.Enabled = true;
if(CurrentPage==(PageCount-1)) lbnNextPage.Enabled = false;
if(CurrentPage==0) lbnPrevPage.Enabled = false;
lblCurrentPage.Text = (CurrentPage+1).ToString(); } public void Page_OnClick(Object sender,CommandEventArgs e)
{
CurrentPage = (int)ViewState["PageIndex"];
PageCount = (int)ViewState["PageCount"]; string cmd = e.CommandName;
//判断cmd,以判定翻页方向
switch(cmd)
{
case "next":
if(CurrentPage<(PageCount-1)) CurrentPage++;
break;
case "prev":
if(CurrentPage>0) CurrentPage--;
break;
} ViewState["PageIndex"] = CurrentPage; ListBind(); }
</script>
<html>
<head>
<title></title>
</head>
<body>
<form runat="server">
共有<asp:Label id="lblRecordCount" ForeColor="red" runat="server" />条记录
当前为<asp:Label id="lblCurrentPage" ForeColor="red" runat="server" />/<asp:Label id="lblPageCount" ForeColor="red" runat="server" />页 <asp:DataList id="score" runat="server"
HeaderStyle-BackColor="#aaaadd"
AlternatingItemStyle-BackColor="Gainsboro"
EditItemStyle-BackColor="yellow"
>
<ItemTemplate>
姓名:<%# DataBinder.Eval(Container.DataItem,"Name") %>
<asp:LinkButton id="btnSelect" Text="编辑" CommandName="edit" runat="server" />
</ItemTemplate>
</asp:DataList>
<asp:LinkButton id="lbnPrevPage" Text="上一页" CommandName="prev" OnCommand="Page_OnClick" runat="server" />
<asp:LinkButton id="lbnNextPage" Text="下一页" CommandName="next" OnCommand="Page_OnClick" runat="server" /> </form>
</body>
</html>