当gridview在页面加载时默认加载第二页

时间:2018-11-08 19:06:40

标签: c# asp.net

我想在页面加载时默认加载gridview的第二页。有可能吗?

//Loads when they page loads
    protected void BindDataExpense()
    {
        dsExpenseTable = objexp.GetCommissionBreakDownTable(name, breakdownType);
        gridlist.DataSource = dsExpenseTable.Tables[0];
        gridlist.DataBind();
    }

//changes the page number
protected void PageIndexChangingExpense(object sender, GridViewPageEventArgs e)
{

    dsExpenseTable = objexp.GetCommissionBreakDownTable(name, breakdownType);
    gridlist.PageIndex = e.NewPageIndex;
    gridlist.DataSource = dsExpenseTable.Tables[0];
    gridlist.DataBind();
}

1 个答案:

答案 0 :(得分:0)

我解决了!我已将此代码添加到gridview的pageindex和pagesize

 <asp:GridView ID="gridlist" runat="server" AutoGenerateColumns="false" GridLines="None"  AllowSorting="True" AllowPaging="True" PageSize="35" PageIndex = "1">