ASPNetPage分页控件的分页控制
netPage.RecordCount 
= int.Parse(ntype.GetCount(" and Upid = '" + zid + "'"));
                DataGrid1.DataSource 
= ntype.GetList2(" and Upid = '" + zid + "", netPage.PageSize.ToString(), netPage.CurrentPageIndex.ToString()).Tables[0].DefaultView;

                DataGrid1.DataBind();
                netPage.CustomInfoText 
= "记录总数:<font color=\"blue\"><b>" + netPage.RecordCount.ToString() + "</b></font>";
                netPage.CustomInfoText 
+= " 总页数:<font color=\"blue\"><b>" + netPage.PageCount.ToString() + "</b></font>";
                netPage.CustomInfoText 
+= " 当前页:<font color=\"red\"><b>" + netPage.CurrentPageIndex.ToString() + "</b></font>";
--------------------------------------------
                
public string GetCount(string str)
        
{
            
string sql = "select count(*) as num from SupplyType where ID <> -1 " + str;
            DataSet ds 
= new DataSet();
            ds 
= DbHelperSQL.Query(sql);
            
if (ds != null)
            
{
                
if (ds.Tables[0].Rows.Count > 0)
                    
return ds.Tables[0].Rows[0]["num"].ToString();

            }

            
return "0";
        }

----------------------------------------------
        
public DataSet GetList2(string str, string pagesize, string index)
        
{
            
int num1 = int.Parse(pagesize);
            
int num2 = int.Parse(index);
            
int count = num1 * num2 - num1;
            
string sql = "select top " + pagesize + " * from SupplyType where ID <> -1 " + str + " and ID not in(select top " +
                count.ToString() 
+ " ID from SupplyType where ID <> -1 " + str + " order by ID )order by ID ";
            
return DbHelperSQL.Query(sql);
        }
posted on 2007-12-19 10:52  小角色  阅读(539)  评论(0)    收藏  举报