DataPager
有一些奇怪的行为。DataPager没有列出比第二页
因此,为了解决这个问题,我有一个DataPagerReapeater
的信息。我有一个DataPager
, ,这是我一起工作的。我有3页,但DataPager
有一些奇怪的行为。
当我在第一页上,然后点击下一页,它会到第二,一切都很好。当我再次点击下一步时,它会进行回发,但不会移至第3页。最后和第一也很好。
但是,当我在第二页上,然后点击下一页时,它将不会移动到第三页,但会停留在第二页上。如果我手动点击第三页然后点击上一页,则会转到第一页。
我真的不明白为什么。
这里是DataPager
:
<asp:DataPager ID="DataPager1" PagedControlID="ReapeaterCSGator" PageSize="5"
runat="server" onprerender="DataPager1_PreRender">
<fields>
<asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="True" FirstPageText="<< First"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
<asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="False" FirstPageText="< Previous"
ShowNextPageButton="False" ShowPreviousPageButton="True" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField ButtonType="Link" ShowLastPageButton="False" LastPageText="Next >"
ShowNextPageButton="True" ShowPreviousPageButton="False" />
<asp:NextPreviousPagerField ButtonType="Link" ShowLastPageButton="True" LastPageText="Last >>"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
</fields>
</asp:DataPager>
下面是我对的PreRender执行代码:
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
IEnumerable<CollaborativeSpace> listCS = LoadCollaborativeSpaces();
// Binding the repeater with the list of documents
ReapeaterCSGator.DataSource = listCS;
ReapeaterCSGator.DataBind();
}
因此,该行为是非常奇怪的,我不知道这个问题可能是什么。
还有人遇到过这样的问题吗?
UPDATE:这里是上负载的方法和我有在那里什么:
ResultPerPages = GetResultsPerPage();
DataPager2.PageSize = ResultPerPages;
DataPager1.PageSize = ResultPerPages;
//We initialize the pager repeater with the same value
ReapeaterCSGator.SetPageProperties(0, ResultPerPages, false);
//We add an handler on item data bound event for sub repeater
ReapeaterCSGator.ItemDataBound += ReapeaterCSGator_ItemDataBound;
//If the user is not post backing
if (!IsPostBack)
{
//We add choices on drop down list "Results per page"
foreach (int choice in NbResultsChoices)
{
NbResultsPerPage.Items.Add(new ListItem(choice + " results per page", choice.ToString(CultureInfo.InvariantCulture)));
}
//We get collaborative spaces from Sharepoint list
//IEnumerable<CollaborativeSpace> listCS = LoadCollaborativeSpaces();
//// Binding the repeater with the list of documents
//ReapeaterCSGator.DataSource = listCS;
更新2: 下面是
public void SetPageProperties(int startRowIndex, int maximumRows, bool databind)
{
ViewState["_startRowIndex"] =startRowIndex;
ViewState["_maximumRows"] = maximumRows;
if (TotalRows > -1)
{
if (TotalRowCountAvailable != null)
{
TotalRowCountAvailable(this, new PageEventArgs((int)ViewState["_startRowIndex"], (int)ViewState["_maximumRows"], TotalRows));
}
}
}
该组件使用形式此处SetPageProperties()后面的代码:http://www.codeproject.com/Articles/45163/Extend-Repeater-to-support-DataPager
问题已解决,似乎datapagerrepeater没有正确实施,现在我发现我可以的来源 修理它。无论如何请帮助
你检查了page.ispostback? – 2012-01-30 16:23:35
仅供参考,请在发布前检查您的帖子是否存在拼写错误等=) – jadarnel27 2012-01-30 16:27:24
我没有发现任何错误的拼写错误!用load_method更新了帖子 – Alnedru 2012-01-30 16:41:15