Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone,

I have a ListView with a DataPager and paging through the numbers works fine, but the Next and Previous link buttons seem to be broken. If I have 3 pages I can navigate through them using the number links, but when I use the Next button it only navigates fine until page number 2, it does not reach the last page. The same happens with the Previous button, but in this case it does not reach the first page. This is a really weird issue since it only occurs in my production farm (SharePoint farms) - in development and QA everything works just fine. Here is a list of things I have tried with no success:

Remove UpdatePanel - I was using an UpdatePanel but I removed it; however the issue still happens
DataPager inside ListView - I moved the DataPager to the LayoutTemplate section
DataPager outside ListView - As it is on the code below
EnableViewStateMac="false" in web.config
Every possible combination of PagePropertiesChanged, PagePropertiesChanging and DataPage OnPreRender - I mean it, every posible combination whether it makes sense or not, like using PagePropertiesChanged and OnPreRender together calling the DataBind ListView method.


Any help or comment on this would be greatly appreciated.


And here is my code:

<asp:ListView runat="server" ID="xtraUsersMngmentListView" OnPagePropertiesChanging="xtraUsersMngmentListView_PagePropertiesChanging">
                <LayoutTemplate>
                    <div id="usersManagement">
                        <table>
                            <tr class="heading">
                                <th class="colh">
                                    <asp:CheckBox ID="xtraSelectAllCheckBox" runat="server" ClientIDMode="Static" />
                                    <span></span>
                                </th>
                                <th class="colh">Username</th>
                            </tr>
                            <asp:PlaceHolder ID="itemPlaceHolder" runat="server"></asp:PlaceHolder>
                        </table>
                    </div>
                </LayoutTemplate>
                <ItemTemplate>
                    <tr>
                        <td class="col">
                            <asp:CheckBox ID="xtraAdminCheckBox" CssClass="usersAdminCheckBox" runat="server" ClientIDMode="Static" ViewStateMode="Enabled" />
                            <span></span>
                            <asp:Label ID="xtraUserID" runat="server" Text='<%# Eval("Login") %>' Visible="false"></asp:Label>
                        </td>
                        <td class="col">
                            <span class="login"><%# Eval("Login") %></span>
                        </td>
                    </tr> 
                </ItemTemplate>
            </asp:ListView>
            <div class="news-nav"  runat="server" id="dataPagerDiv">
                <asp:DataPager ID="xtraUsersMngmentPager" runat="server" PagedControlID="xtraUsersMngmentListView" PageSize="10">
                    <Fields>
                        <asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="False" ShowNextPageButton="False" ShowPreviousPageButton="true" PreviousPageText="Prev" />
                        <asp:NumericPagerField CurrentPageLabelCssClass="current" />
                        <asp:NextPreviousPagerField ButtonType="Link" ShowLastPageButton="False" ShowNextPageButton="true" ShowPreviousPageButton="False" NextPageText="Next" />
                    </Fields>
                </asp:DataPager>
            </div>



C#
protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
    	if (!Page.IsPostBack)
	{
		BindExtradiumUsers();
	}
        }
        catch (Exception ex)
        {
            ex.Log();
        }
        

    }
protected void xtraUsersMngmentPager_PreRender(object sender, EventArgs e)
{
     BindExtradiumUsers();
}
		
protected void xtraUsersMngmentListView_PagePropertiesChanged(object sender, EventArgs e)
{
     BindExtradiumUsers();   
}

protected void xtraUsersMngmentListView_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
     xtraUsersMngmentPager.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
}
		
private void BindExtradiumUsers()
{
            UserCollection usersByVendor = new UserCollection();
            
            usersByVendor = ExtradiumUsersController.GetUsersByCurrentUserVendor(SPContext.Current.Site, SPContext.Current.Site.RootWeb, vendor, logins);

            xtraUsersMngmentListView.DataSource = usersByVendor;
            xtraUsersMngmentListView.DataBind();
}


Thanks in advance,
Kabir
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900