protected void Page_Load(object sender, EventArgs e)
{
string MM = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char[] charmm = MM.ToCharArray();
GridView GridView2 = new GridView();
GridView2.AllowPaging = true;
GridView2.PageSize = 5;
form1.Controls.Add(GridView2);
GridView2.DataSource = MM.ToCharArray();
GridView2.DataBind();
GridView2.PageIndexChanging += new GridViewPageEventHandler(GridView2_PageIndexChanging);
}
protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView GridView2 = sender as GridView;
GridView2.PageIndex = e.NewPageIndex;
string MM = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char[] charmm = MM.ToCharArray();
GridView2.DataSource = charmm;
GridView2.DataBind();
}
紅色處為分頁事件
如果用GridView本身的分页程序,动态添加分页事件和属性就行了
可以用studio生成一个GridView静态分页的代码,复制过来就ok了
gridview有自带的分页功能,你选择它的属性就行了