最后一页和第一页在MVC分页中给出了异常

时间:2016-04-18 12:34:36

标签: asp.net gridview paging

 protected void gvValues_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvValues.PageIndex = e.NewPageIndex;
            this.FillData();
        }

分页工作正常,但是当我在上一个或第一个时,它会给我一个错误

Input string was not in a correct format.

1 个答案:

答案 0 :(得分:0)

编写以下代码:

protected void gvValues_PageIndexChanging(object sender, GridViewPageEventArgs e){

    GridView1.PageIndex = e.NewPageIndex;

    //rebind your gridview - GetSource(),Datasource of your GirdView
    GridView1.DataSource = GetSource();
    GridView1.DataBind();

}