单击链接按钮后在gridview上分页

时间:2012-11-14 08:46:19

标签: c# asp.net pagination

我有一个网格视图,可以通过点击链接按钮生成。我无法在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);

    }
}

Gridview分页

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。如何在这种情况下为子网格启用分页?

0 个答案:

没有答案