实现效果,通过设置css中div宽度来改变列数。
list.aspx.cs
if (!IsPostBack)
{
Dqt.Reporter.BLL.user userbll = new Dqt.Reporter.BLL.user();
int pageSize = 32;
int pageindex = 1;
if (!string.IsNullOrEmpty(Request.QueryString["page"]))
pageindex = int.Parse(Request.QueryString["page"]);
pageindex = pageindex < 1 ? 1 : pageindex;
int totle = userbll.GetRecordCount("");
pager1.RecordCount = totle;
if (totle > pageSize)
pager1.Visible = true;
pager1.PageUrl = "/gaojian/list.aspx";
pager1.PageSize = pageSize;
pager1.DestPage = pageindex;
List<Dqt.Reporter.Model.user> usermodellist = userbll.GetModelList("", pageindex, pageSize, "UserJiFen desc");
rptlist.DataSource = usermodellist;
rptlist.DataBind();
}
public List<Dqt.Reporter.Model.user> GetModelList(string strWhere, int pageNo, int pageSize, string orderBy)
{
DataSet ds = dal.GetList(strWhere, pageNo, pageSize, orderBy);
return DataTableToList(ds.Tables[0]);
}
public DataSet GetList(string strWhere, int pageNo, int pageSize, string orderBy)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select UserId,UserName,UserPassword,Email,Tel,UserSex,TureName,UserAge,UserXingQu,UserTouXiang,LastLoginIp,UserJiFen,UserZhuCeTime,LastLoginTime,Type,SelfIntroduction,Tuijian,ClassNum,SchoolId ");
strSql.Append(" FROM user ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
strSql.Append(" Order By " + orderBy + " ");
strSql.Append(" limit " + ((pageNo - 1) * pageSize) + "," + pageSize + " ");
return DbHelperMySQL.Query(strSql.ToString());
}
list.aspx
<div class="alllist">
<ul>
<asp:Repeater ID="rptlist" runat="server">
<ItemTemplate>
<li>
<a href="/usercenter/wodegaojian.aspx?uid=<%#Eval("UserId") %>">
<img src="<%#Eval("UserTouXiang") %>" title="<%#Eval("UserName") %>" οnerrοr="this.src='/img/pinglun_img.gif';" />
</a>
<span><a href="/usercenter/wodegaojian.aspx?uid=<%#Eval("UserId") %>" title="<%#Eval("UserName") %>">
<%#Dqt.Reporter.Common.MFunction.Text_Substring( Eval("UserName").ToString(),10,"...") %></a>
</span>
<br />
<p> <%#Dqt.Reporter.Common.MFunction.GetClass(Eval("ClassNum").ToString()) %></p>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</div>
<div class="pageses">
<uc4:pager ID="pager1" runat="server" Visible="false" />
</div>