日期:2014-05-19  浏览次数:20348 次

关于datagrid的自定义分页问题 求教
如题   从vs2003过来的人应该对这个控件又爱又恨
现在我需要的是   怎么让该控件按我想要的式样分页  
比如我在数据库里的某个字段判定   如果该字段为0的时候出现5个   然后分页  
否则不分页
先谢谢大家了   提供思路者给分!!!

------解决方案--------------------
用分页控件吧
------解决方案--------------------
一楼说得对;webdiyer的分页控件很不错的,楼主不妨一试……
------解决方案--------------------
用分页控件.或 自己写 分页代码.

www.webdiyer.com
------解决方案--------------------
支持用webdiyer分页控件,这个控件确实不错!
------解决方案--------------------
我有个好控件,如果需要请加我QQ:110234 验证时注明csdn即可
------解决方案--------------------
自己写自定义分页哈
------解决方案--------------------
先读条件,然后设置是否分页,再绑定数据
------解决方案--------------------
不想自己头疼还是使用分页控件...
------解决方案--------------------
GRIDVIEW?
------解决方案--------------------
看我对DataList的分页方法 样式也不错哦
public void getDataList(string strSql, string tableName)
{
PagedDataSource objPds = new PagedDataSource();
DataSet ds = new DataSet();
ds = DBManage.getDs(strSql, tableName);
objPds.DataSource = ds.Tables[0].DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 10;
int PageSum=objPds.PageCount;
if (PageSum == 1)
{
PageView.Text = " ";
}
else
{
int CurPage;

//当前页面从Page查询参数获取
if (Request.QueryString[ "Page "] != null)
CurPage = Convert.ToInt32(Request.QueryString[ "Page "]);
else
CurPage = 1;
objPds.CurrentPageIndex = CurPage - 1;
//循环上限
int totale;
if (PageSum <10)
totale=PageSum;
else
totale=10;
if (CurPage> PageSum)
totale=PageSum%10;

PageView.Text = " <a class= 'nolink '> 当前: " + CurPage + "页,共 " + PageSum + "页 </a> ";
PageView.Text += " <a class= 'page ' href= '? '> 首页 </a> ";
if (!objPds.IsFirstPage)
PageView.Text += " <a class= 'page ' href= '?Page= " + (CurPage - 1) + " '> 上一页 </a> ";
else
PageView.Text += " <a class= 'nolink '> 上一页 </a> ";
for (int i = 1; i <= totale; i++)
{
int pageid;
if (CurPage%10==0)
pageid = i + (CurPage / 10) * 10 -1;
else
pageid=i + (CurPage / 10) * 10;
if (pageid > PageSum)
break;
if (i!=CurPage%10)
PageView.Text += ( " <a class= 'page ' href= '?Page= " + pageid + " '> " + pageid + " </a> ");
else
PageView.Text += ( " <a class= 'thispage ' href= '?Page= " + pageid + " '> " + pageid + " </a> ");