日期:2014-05-17 浏览次数:20489 次
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" AlwaysShow="true" PageSize="20"
FirstPageText="首页" NextPageText="下一页" PrevPageText="上一页" LastPageText="尾页"
OnPageChanged="AspNetPager1_PageChanged" CssClass="pages">
</webdiyer:AspNetPager>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
AspNetPager1.RecordCount = getTotalRecore();
bindData();
}
}
private void bindData()
{
string strResult = "";
string strSQL = "proc_Comm_Affairs_getList";
using (DBOperate dbo = new DBOperate())
{
SqlParameter[] sqlPa = new SqlParameter[]
{
DBOperate .MakeInParam ("@PageIndex",AspNetPager1 .CurrentPageIndex ),
DBOperate .MakeInParam ("@PageSize",AspNetPager1 .PageSize )
};
DataTable dt = dbo.ExecuteTable(strSQL ,sqlPa ,CommandType.StoredProcedure );
rp_NewsList.DataSource = dt;
rp_NewsList.DataBind();
}
}
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
bindData();
}
private int getTotalRecore()
{
int iTotalRecore = 0;
using (DBOperate dbo = new DBOperate())
{
string strSQL = "select count(*) from Comm_Affairs where isShow='1' and catalogID='1'";