过滤网页视图与页面问题

时间:2015-09-12 22:10:19

标签: c# asp.net gridview

你好我有网格视图,按页面获取10条记录。

问题是,如果我移动到搜索结果的任何其他页面,过滤器将移除,网格将显示所有结果。

protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            gridprod.DataSource = d.getprod();
            gridprod.DataBind();
        }


    }

protected void btnsearch1_Click(object sender, ImageClickEventArgs e)
    {
        gridprod.DataSource = d.Searchprod(lblfield.SelectedValue, txtsearch.Text);
        gridprod.DataBind();
        gridprod.SelectedIndex = -1;
    }

protected void OnPageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gridprod.PageIndex = e.NewPageIndex;
        gridprod.DataSource = d.getprod();
        gridprod.DataBind();
    }

1 个答案:

答案 0 :(得分:0)

如果您已经应用了搜索过滤器,那么您应该使用此页面:

leaders = User.objects.filter(~Q(submissions=None)) \
        .filter(submissions__status='approved') \
        .annotate(total=Sum('submissions__task__points')) \
        .order_by('-total')