DataPager
이상한 동작이 있습니다.DataPager가 두 번째 페이지 이상을 나열하지 않습니다
문제를 해결하려면 정보가있는 DataPagerReapeater
이 있어야합니다. 그리고 나는 함께 일하기 위해 만든 DataPager
, 을 가지고 있습니다. 3 페이지가 있지만, DataPager
은 이상한 행동을합니다.
첫 번째 페이지를 클릭하고 다음을 클릭하면 두 번째로 넘어갑니다. 모든 것이 정상입니다. 다음에 다시 클릭하면 다시 게시되지만 3 번째 페이지로 이동하지는 않습니다. 마지막이고 처음에는 잘 작동합니다.
하지만 두 번째 페이지에서 다음을 클릭하면 세 번째 페이지로 이동하지 않지만 두 번째 페이지는 그대로 유지됩니다. 수동으로 세 번째 페이지를 클릭하고 이전을 클릭하는 경우와 동일하게 첫 번째 페이지로 이동합니다.
나는 이유를 정말로 모른다. 여기
는DataPager
입니다 :
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();
}
그래서, 행동이 정말 이상하고 내가 문제가 될 수있는 것을 아무 생각이 : 여기
<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>
내가 미리 렌더링에 실행 코드입니다 .
누구든지 그런 문제에 직면 했습니까? 그 구성 요소가 여기에 양식을 사용
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() 뒤에있는 코드는 여기 :
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 : http://www.codeproject.com/Articles/45163/Extend-Repeater-to-support-DataPager
문제가 해결되면 datapagerrepeater가 올바른 방법으로 구현되지 않은 것처럼 보입니다. 그것을 고쳐라. 어쨌든 도와 줘서 고마워.
page.ispostback을 선택 했습니까? –
참고하시기 바랍니다, 글을 올리시기 전에 철자법 오류 등을 확인하십시오.) – jadarnel27
잘못된 철자 오류를 발견하지 못했습니다! load_method로 게시물을 업데이트했습니다. – Alnedru