DataView dv = ds.Tables["Unit"].DefaultView;
dv.RowFilter = SqlWhere;
dv.Sort = SortList.SelectedValue.ToString();
PagedDataSource page = new PagedDataSource();
page.DataSource = dv;
page.AllowPaging = true;
page.PageSize = Int32.Parse(ResultList.SelectedValue);
page.CurrentPageIndex = CurrentPage;
lblCurrentPage.Text = "Page: " + (CurrentPage + 1).ToString() + " of " +
page.PageCount.ToString();
// Disable Prev or Next buttons if necessary
cmdPrev.Enabled = !page.IsFirstPage;
cmdNext.Enabled = !page.IsLastPage;
invList.DataSource = page;
invList.DataBind();
public int CurrentPage
{
get
{
// look for current page in ViewState
object o = this.ViewState["_CurrentPage"];
if (o == null)
return 0; // default page index of 0
else
return (int)o;
}
set
{
this.ViewState["_CurrentPage"] = value;
}
}
但它现在显示这样的错误invList.DataBind();
Index 4 is either negative or above rows count.
描述
An unhandled exception occurred during the execution of the current web request.
Please review the stack trace for more information about the error and where it
originated in the code.
异常详情
System.IndexOutOfRangeException: Index 1 is either negative or above rows count.
谁能帮忙?