那么如何让gridview的自动分页,点下一页时触发Page_Load事件。
5 个解决方案
#1
触发gridview的pageindexchanging事件。
http://www.cnblogs.com/luqingsong/archive/2012/05/12/2497137.html
#2
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// 绑定数据源到GridView
this.BindGridView();
}
}
public void BindGridView()
{//里面绑定
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
BindGridView(); //自定义的数据绑定方法,重新绑定数据源
}
#3
会触发gridview的pageindexchanging事件,在这个事件里面来重新绑定数据
#5
GridViedw自定义分页功能
//自定义分页属性
public GridView myDataGrid
{
get
{
return mydataGrid;
}
set
{
mydataGrid=value;
}
}
public DataSet myDataSet
{
get
{
return mydataSet;
}
set
{
mydataSet=value;
}
}
//加载分页设定的必要属性
public partial class _Default : System.Web.UI.Page
{
public SqlDb sd = new SqlDb();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DbBind();//CodeGo.net/
}
string strsql = "SELECT 产品编号, 产品, 单价, 库存量, 已订购量, 订单日期,单价 * 已订购量 AS 订货金额 FROM tb_OrderForm";
DataSet ds = sd.ExceDS(strsql);
myPagenavigate1.myDataGrid = GridView1;//设定要使用自定义分页用户控件的GridView
myPagenavigate1.myDataSet = ds;//设定数据源
if (ds.Tables[0].Rows.Count == 0)
myPagenavigate1.Visible = false;
else
myPagenavigate1.Visible = true;
}
//自定义分页属性
public GridView myDataGrid
{
get
{
return mydataGrid;
}
set
{
mydataGrid=value;
}
}
public DataSet myDataSet
{
get
{
return mydataSet;
}
set
{
mydataSet=value;
}
}
//加载分页设定的必要属性
public partial class _Default : System.Web.UI.Page
{
public SqlDb sd = new SqlDb();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DbBind();//CodeGo.net/
}
string strsql = "SELECT 产品编号, 产品, 单价, 库存量, 已订购量, 订单日期,单价 * 已订购量 AS 订货金额 FROM tb_OrderForm";
DataSet ds = sd.ExceDS(strsql);
myPagenavigate1.myDataGrid = GridView1;//设定要使用自定义分页用户控件的GridView
myPagenavigate1.myDataSet = ds;//设定数据源
if (ds.Tables[0].Rows.Count == 0)
myPagenavigate1.Visible = false;
else
myPagenavigate1.Visible = true;
}
#1
触发gridview的pageindexchanging事件。
http://www.cnblogs.com/luqingsong/archive/2012/05/12/2497137.html
#2
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// 绑定数据源到GridView
this.BindGridView();
}
}
public void BindGridView()
{//里面绑定
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
BindGridView(); //自定义的数据绑定方法,重新绑定数据源
}
#3
会触发gridview的pageindexchanging事件,在这个事件里面来重新绑定数据
#4
#5
GridViedw自定义分页功能
//自定义分页属性
public GridView myDataGrid
{
get
{
return mydataGrid;
}
set
{
mydataGrid=value;
}
}
public DataSet myDataSet
{
get
{
return mydataSet;
}
set
{
mydataSet=value;
}
}
//加载分页设定的必要属性
public partial class _Default : System.Web.UI.Page
{
public SqlDb sd = new SqlDb();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DbBind();//CodeGo.net/
}
string strsql = "SELECT 产品编号, 产品, 单价, 库存量, 已订购量, 订单日期,单价 * 已订购量 AS 订货金额 FROM tb_OrderForm";
DataSet ds = sd.ExceDS(strsql);
myPagenavigate1.myDataGrid = GridView1;//设定要使用自定义分页用户控件的GridView
myPagenavigate1.myDataSet = ds;//设定数据源
if (ds.Tables[0].Rows.Count == 0)
myPagenavigate1.Visible = false;
else
myPagenavigate1.Visible = true;
}
//自定义分页属性
public GridView myDataGrid
{
get
{
return mydataGrid;
}
set
{
mydataGrid=value;
}
}
public DataSet myDataSet
{
get
{
return mydataSet;
}
set
{
mydataSet=value;
}
}
//加载分页设定的必要属性
public partial class _Default : System.Web.UI.Page
{
public SqlDb sd = new SqlDb();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DbBind();//CodeGo.net/
}
string strsql = "SELECT 产品编号, 产品, 单价, 库存量, 已订购量, 订单日期,单价 * 已订购量 AS 订货金额 FROM tb_OrderForm";
DataSet ds = sd.ExceDS(strsql);
myPagenavigate1.myDataGrid = GridView1;//设定要使用自定义分页用户控件的GridView
myPagenavigate1.myDataSet = ds;//设定数据源
if (ds.Tables[0].Rows.Count == 0)
myPagenavigate1.Visible = false;
else
myPagenavigate1.Visible = true;
}