<SortedDescendingCellStyle BackColor="#FCF6C0" />
<SortedDescendingHeaderStyle BackColor="#820000" />
</asp:GridView>
PageSize="4"
PagingButtonSpacing="2px" AlwaysShow="True" ShowBoxThreshold="1"CurrentPageButtonPosition="Beginning" ShowMoreButtons="False"
onpagechanged="AspNetPager1_PageChanged">>
</webdiyer:AspNetPager>
</div>
</form>
</body>
</html>
后台代码如下:
using System;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Data.SqlClient;
namespace fenye2
{
public partial class fenye21 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
dobind();
}
}
public void dobind()
{
SqlConnection cnn = new SqlConnection("Data Source=.;Initial Security=True");
string sql = "select * from Info ";
SqlDataAdapter sda = new SqlDataAdapter(sql,cnn);
DataSet ds = new DataSet();
sda.Fill(ds,"Info");
PagedDataSource pds = new PagedDataSource();
pds.DataSource = ds.Tables["Info"].DefaultView;
AspNetPager1.RecordCount = pds.Count;
// AspNetPager1.RecordCount = ds.Tables["Info"].DefaultView.Count;pds.PageSize = AspNetPager1.PageSize;
GridView1.PageIndex = AspNetPager1.CurrentPageIndex - 1;
this.GridView1.DataSource = pds;
this.GridView1.DataBind();
}
protected void AspNetPager1_PageChanged(object sender, EventArgs e){
dobind();
}
}
}
希望可以对初学者有帮助 Catalog=Stu;Integrated
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-30496-3.html
为什么韩国出专辑一定要把头发弄的五颜六色
打
快射炮