D
Daniel Bauke
i cannot find the rule why from time to time i'm receiving "Invalid
CurrentPageIndex value. It must be >= 0 and < the PageCount."
at the beginning it looked like it was something with weird browsers, but
looks like it's not a rule.
i suppose it started failing when i added:
protected void SearchResultsItemCreated(Object sender,
DataGridItemEventArgs e) {
DataGridItem item = e.Item;
if (item.ItemType == ListItemType.Pager) {
TableCell pager = (TableCell) item.Controls[0];
for (int i=0; i < pager.Controls.Count; i++) {
Control ctl = pager.Controls;
if (ctl is LinkButton) {
LinkButton lnk = (LinkButton) ctl;
lnk.CssClass = "navPage";
}
}
}
}
as a method for OnItemCreated.
stack trace of the error follows:
System.Web.HttpUnhandledException: Exception of type
System.Web.HttpUnhandledException was thrown. --->
System.Web.HttpException: Invalid CurrentPageIndex value. It must be >= 0
and < the PageCount.
at System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean
useDataSource)
at System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e)
at System.Web.UI.WebControls.BaseDataList.DataBind()
at PB.Portal.Site.Portlets.Common.Search.SearchResultsBind()
at
PB.Portal.Site.Portlets.Common.Search.SearchResults_PageIndexChanged(Object
source, DataGridPageChangedEventArgs e)
at
System.Web.UI.WebControls.DataGrid.OnPageIndexChanged(DataGridPageChangedE
ventArgs e)
at System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source,
EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source,
EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
at
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.R
aisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain()
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain()
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionS
tep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously)
--------
on PageIndexChanged i have simple:
private void SearchResults_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEventArgs e) {
SearchResults.CurrentPageIndex = e.NewPageIndex;
SearchResultsBind();
}
and SearchResultsBind() does:
private void SearchResultsBind() {
SearchResults.PageSize = ResultsPerPage;
DataSet sr = SqlResult;
if (sr.Tables.Count > 0) {
DataView dv = sr.Tables[0].DefaultView;
dv.Sort = OrderBy;
SearchResults.DataSource = dv;
SearchResults.DataBind();
}
// ...
}
and.. i have no idea what it is..
CurrentPageIndex value. It must be >= 0 and < the PageCount."
at the beginning it looked like it was something with weird browsers, but
looks like it's not a rule.
i suppose it started failing when i added:
protected void SearchResultsItemCreated(Object sender,
DataGridItemEventArgs e) {
DataGridItem item = e.Item;
if (item.ItemType == ListItemType.Pager) {
TableCell pager = (TableCell) item.Controls[0];
for (int i=0; i < pager.Controls.Count; i++) {
Control ctl = pager.Controls;
if (ctl is LinkButton) {
LinkButton lnk = (LinkButton) ctl;
lnk.CssClass = "navPage";
}
}
}
}
as a method for OnItemCreated.
stack trace of the error follows:
System.Web.HttpUnhandledException: Exception of type
System.Web.HttpUnhandledException was thrown. --->
System.Web.HttpException: Invalid CurrentPageIndex value. It must be >= 0
and < the PageCount.
at System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean
useDataSource)
at System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e)
at System.Web.UI.WebControls.BaseDataList.DataBind()
at PB.Portal.Site.Portlets.Common.Search.SearchResultsBind()
at
PB.Portal.Site.Portlets.Common.Search.SearchResults_PageIndexChanged(Object
source, DataGridPageChangedEventArgs e)
at
System.Web.UI.WebControls.DataGrid.OnPageIndexChanged(DataGridPageChangedE
ventArgs e)
at System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source,
EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source,
EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
at
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.R
aisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain()
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain()
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionS
tep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously)
--------
on PageIndexChanged i have simple:
private void SearchResults_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEventArgs e) {
SearchResults.CurrentPageIndex = e.NewPageIndex;
SearchResultsBind();
}
and SearchResultsBind() does:
private void SearchResultsBind() {
SearchResults.PageSize = ResultsPerPage;
DataSet sr = SqlResult;
if (sr.Tables.Count > 0) {
DataView dv = sr.Tables[0].DefaultView;
dv.Sort = OrderBy;
SearchResults.DataSource = dv;
SearchResults.DataBind();
}
// ...
}
and.. i have no idea what it is..