我有一个网格视图,它在单击链接按钮时生成。我无法在 gridview 上坚持分页。顺便说一下,生成的网格视图是嵌套的网格视图。这里有一些代码示例。
链接按钮点击事件:
protected void lbtnBOLNo_Click(object sender, EventArgs e)
{
LinkButton btn = (LinkButton)(sender);
string yourValue = btn.CommandArgument;
Session["globalselected"] = yourValue;
populategridview1(ddl_market.SelectedItem.Text, dt_to_integer(Picker1.CalendarDateString), dt_to_integer(Picker2.CalendarDateString), ddl_metric.SelectedItem.Text, yourValue, cond1.SelectedValue, cond2.SelectedValue, cond3.SelectedValue);
}
页面加载
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
lbl_status.Text = "";
populategridview3(ddl_days.SelectedItem.Text, ddl_days1.Text);
populategridview1(ddl_market.SelectedItem.Text, dt_to_integer(Picker1.CalendarDateString), dt_to_integer(Picker2.CalendarDateString), ddl_metric.SelectedItem.Text, Session["globalselected"].ToString(), cond1.SelectedValue, cond2.SelectedValue, cond3.SelectedValue);
}
}
网格视图分页
protected void GridView3_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView gvTemp = (GridView)sender;
GridView3.PageIndex = e.NewPageIndex;
populategridview3(ddl_days.SelectedItem.Text, ddl_days1.Text);
}
我的问题是单击链接按钮时,我的网格视图会引发错误,因为 Session["globalselected"] 在页面加载中为空,稍后会对其进行初始化。但是,我需要在页面加载中调用此方法 populategridview1 以确保分页适用于 gridview。在这种情况下,如何为子网格启用分页?