关于AspNetPage控件的问题!!
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
int total;
total=(int)SqlHelper.ExecuteScalar(CommandType.StoredProcedure, "show_o ",
new SqlParameter( "@pagesize ", 10),
new SqlParameter( "@pageindex ", 1),
new SqlParameter( "@docount ", true)
);
this.AspNetPager1.RecordCount = total;
BindData();
}
}
void BindData()
{
SqlDataReader sdr = SqlHelper.ExecuteReader(CommandType.StoredProcedure, "show_o ",
new SqlParameter( "@pagesize ", AspNetPager1.PageSize),
new SqlParameter( "@pageindex ", AspNetPager1.StartRecordIndex),
new SqlParameter( "@docount ", false)
);
this.DataList1.DataSource = sdr;
this.DataList1.DataBind();
}
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
BindData();
}
存储过程在数据库里面测试都没有问题,但是到了页面的时候不知道怎么回事,第一页显示正确1-10条记录,第二页显示就变成101-110记录翻页了,我设置的是10条记录,不知道到底是什么原因,我找了很久了!试了很多的数据分页存储过程!!
------解决方案--------------------protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
int total;
total=(int)SqlHelper.ExecuteScalar(CommandType.StoredProcedure, "show_o ",
new SqlParameter( "@pagesize ", 10),
new SqlParameter( "@pageindex ", 1),
new SqlParameter( "@docount ", true)
);
this.AspNetPager1.RecordCount = total;
BindData();
}
}
void BindData()