DataPager
奇妙な振る舞いがあります。
それで、問題を特定するために、私はDataPagerReapeater
情報を持っています。そして、私はDataPager
一緒に働くために作ったを持っています。3ページありますが、DataPager
動作がおかしいです。
最初のページを表示して[次へ]をクリックすると、2番目に移動し、すべて問題ありません。[次へ]をもう一度クリックすると、ポストバックは実行されますが、3ページ目に移動しません。最後と最初も正常に動作します。
しかし、2ページ目にいて[次へ]をクリックすると、3ページ目には移動せず、2ページ目に留まります。同じように、手動で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();
}
ですから、その振る舞いは本当に奇妙で、何が問題なのかわかりません。
他の誰かがそのような問題に直面しましたか?
更新:ここにロードメソッドと私がそこに持っているものがあります:
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:これがSetPageProperties()の背後にあるコードです
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));
}
}
}
そのコンポーネントはここから使用されました:http://www.codeproject.com/Articles/45163/Extend-Repeater-to-support-DataPager
問題は解決しました。datapagerrepeaterが正しい方法で実装されていなかったようです。修正できるソースが見つかったので、とにかく助けてくれてありがとう