All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
ASP.NET组件DataGrid的分页实用方法_.net资料_编程技术

Writer: aaa Article type: Programming skills(编程技巧) Time: 2013/12/11 8:29:42 Browse times: 286 Comment times: 0

ASP.NET组件DataGrid的分页实用方法_.net资料_编程技术


Head photo

Go homepage
Upload pictures
Write articles

ASP.NET组件DataGrid的分页实用方法_.net资料_编程技术-你的首页-uuhomepage.com

  查了网上资料,关于这个DataGrid分页实在是太多太多方法,有些解决方法过于Trick,有些则效率较低,这里提供一个不太麻烦,也效率尚可(通过Session缓存DataSet)的方法:

  拖动DataGrid到WebForms,从DataGrid的属性栏中选择Columns打开DataGrid Properties自定义对话框,选择Paging分页,Allow paging, Page size: 20。

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!this.IsPostBack)
{
sqlDataAdapter1.Fill(dataSet11);
Session["CopyYear"]=dataSet11;
DataGrid1.DataSource = dataSet11.Tables[0].DefaultView;
DataGrid1.DataBind();
}
}
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex=e.NewPageIndex;
dataSet11=(DataSet1)Session["CopyYear"];
DataGrid1.DataSource = dataSet11.Tables[0].DefaultView;
DataGrid1.DataBind();
}

  在页面上添加上述代码,OK






There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.