复制代码 代码如下:
<div>
<webdiyer:AspNetPager runat="server"
AlwaysShow="True" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页"
onpagechanged="AspNetPagerAskAnswer_PageChanged" PrevPageText="上一页"
PageSize="15">
</webdiyer:AspNetPager>
<br />
</div>
复制代码 代码如下:
private void bind(){SqlConnection connection= new SqlConnection(ConfigurationManager.ConnectionStrings["tianzi"].ConnectionString);
SqlCommand cmd = new SqlCommand("select * from ask", connection);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
AspNetPagerAskAnswer.PageSize = 5;//设置分页大小
AspNetPagerAskAnswer.RecordCount = AskManager.GetAllAsks().Rows.Count;//设置总数据条数
sda.Fill(ds, AspNetPagerAskAnswer.PageSize * (AspNetPagerAskAnswer.CurrentPageIndex - 1), AspNetPagerAskAnswer.PageSize, "asks");//固定不变的
RepeaterAskAnswer.DataSource = ds.Tables["asks"];
RepeaterAskAnswer.DataBind();
}
复制代码 代码如下:
protected void AspNetPagerAskAnswer_PageChanged(object sender, EventArgs e)
{
bind();
}
新闻热点
疑难解答
图片精选