![]() |
#2
lmyh52012007-04-05 17:36
|
谁有分页的代码,我急用
![]() |
#2
lmyh52012007-04-05 17:36
你找什么分页的代码?是.net的吗?
|
![]() |
#3
makewelldone2007-04-05 17:41
是的你有吗? |
![]() |
#4
lmyh52012007-04-05 17:48
private void setAllUsers()
{ literal.Text=""; int pageSize=5; int pageNo=0; Session["PageNo"]=Request["pageNo"]; if(Session["PageNo"]==null) { pageNo=1; } else { pageNo=Convert.ToInt16(Session["PageNo"]); } int no=pagination.getCount(); int pageCount=no/pageSize; if(no%pageSize!=0) { pageCount++; } //为下拉列表框填值 for(int i=1;i<=pageCount;i++) { ddl.Items.Add(i.ToString()); } ddl.AutoPostBack=true; DataTable dt=pagination.getRecords(pageSize*pageNo); for(int i=0;i<(pageNo-1)*pageSize;i++) { dt.Rows.RemoveAt(0); } StringBuilder str=new StringBuilder(); str.Append("<table cellSpacing='1'cellPadding='2' width='100%' bgColor='#cccccc' border='0'>"); for(int i=0;i<dt.Rows.Count;i++) { if(i%2==0) { str.Append("<tr bgcolor='#f5f5f5'>"); str.Append("<td width='4%' align='center' class='txt12_18_cg' align='center' height='26'>"+(int)(i+1)+"</td>"); if(dt.Rows[i]["userName"]!=null) { str.Append("<td width='10%' class='txt12_18_cg' height='26' align='center'><a href='user_data.aspx?uName="+dt.Rows[i]["userName"].ToString()+"'>"+dt.Rows[i]["userName"].ToString()+"</a></td>"); } else { str.Append("<td width='10%' class='txt12_18_cg' height='26' align='center'> </td>"); } if(dt.Rows[i]["company"]!=null) { str.Append("<td class='txt12_18_cg' height='26' align='center'>"+dt.Rows[i]["company"].ToString()+"</td>"); } else { str.Append("<td class='txt12_18_cg' height='26' align='center'> </td>"); } if(dt.Rows[i]["contact"]!=null) { str.Append("<td width='8%' class='txt12_18_cg' height='26' align='center'>"+dt.Rows[i]["contact"].ToString()+"</td>"); } else { str.Append("<td width='8%' class='txt12_18_cg' height='26' align='center'> </td>"); } if(dt.Rows[i]["phone"]!=null) { str.Append("<td width='12%' class='txt12_18_cg' height='26' align='center'>"+dt.Rows[i]["phone"].ToString()+"</td>"); } else { str.Append("<td width='12%' class='txt12_18_cg' height='26' align='center'> </td>"); } if(dt.Rows[i]["addTime"]!=null) { str.Append("<td width='10%' class='txt12_18_cg' height='26' align='left'>"+dt.Rows[i]["addTime"].ToString()+"</td>"); } else { str.Append("<td width='10%' class='txt12_18_cg' height='26' align='center'> </td>"); } str.Append("</tr>"); } else { str.Append("<tr bgcolor='#ffffff'>"); str.Append("<td width='4%' align='center' class='txt12_18_cg' align='center' height='26'>"+(int)(i+1)+"</td>"); if(dt.Rows[i]["userName"]!=null) { str.Append("<td width='10%' class='txt12_18_cg' height='26' align='center'><a href='user_data.aspx?uName="+dt.Rows[i]["userName"].ToString()+"'>"+dt.Rows[i]["userName"].ToString()+"</td>"); } else { str.Append("<td width='10%' class='txt12_18_cg' height='26' align='center'> </td>"); } if(dt.Rows[i]["company"]!=null) { str.Append("<td class='txt12_18_cg' height='26' align='center'>"+dt.Rows[i]["company"].ToString()+"</td>"); } else { str.Append("<td class='txt12_18_cg' height='26' align='center'> </td>"); } if(dt.Rows[i]["contact"]!=null) { str.Append("<td width='8%' class='txt12_18_cg' height='26' align='center'>"+dt.Rows[i]["contact"].ToString()+"</td>"); } else { str.Append("<td width='8%' class='txt12_18_cg' height='26' align='center'> </td>"); } if(dt.Rows[i]["phone"]!=null) { str.Append("<td width='12%' class='txt12_18_cg' height='26' align='center'>"+dt.Rows[i]["phone"].ToString()+"</td>"); } else { str.Append("<td width='12%' class='txt12_18_cg' height='26' align='center'> </td>"); } if(dt.Rows[i]["addTime"]!=null) { str.Append("<td width='10%' class='txt12_18_cg' height='26' align='left'>"+dt.Rows[i]["addTime"].ToString()+"</td>"); } else { str.Append("<td width='10%' class='txt12_18_cg' height='26' align='center'> </td>"); } str.Append("</tr>"); } } str.Append("</table>"); literal.Text=str.ToString(); pgInfo.Text="["+pageNo+"]/["+pageCount+"]"; if(pageNo==1) { pgFirst.Text="[首页]"; pgPre.Text="[上一页]"; } else { pgFirst.Text="[<a href='in_hi.aspx?pageNo="+1+"'>首页</a>]"; pgPre.Text="[<a href='in_hi.aspx?pageNo="+(pageNo-1)+"'>上一页</a>]"; } if(pageCount==pageNo || pageCount==0) { pgNext.Text="[下一页]"; pgLast.Text="[尾页]"; } else { pgLast.Text="[<a href='in_hi.aspx?pageNo=" +pageCount + "'>尾页</a>]"; pgNext.Text="[<a href='in_hi.aspx?pageNo=" + (pageNo+1) + "'>下一页</a>]"; } } |