TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Cassie Mod
NA
488
71.2k
repeater is empty afther third page and more
Mar 14 2017 9:28 AM
HI, ive got a strange question.
i have an aspx site with a repeater on it. The repeater doesn't work properly.
the first 2 pages works perfectly. The third and further doesn;t snow any result, but my datasource wich is used as the repeater datasource contains 10 items. Why isn't it showing in my page ????
Here is my code. and some extra information.
total amount of users is 1079.
10 users are shown on a page. so 1079/10 + 1 = 108 pages.
page 1 works fine
page 2 works fine
page 3 and futher don't show results.
public
partial
class
UsersControl : CompleetControl
{
protected
Features Features;
private
User _user;
private
Guid _sessionId;
public
int
PageSize = 5;
private
static
int
_pageCount;
private
static
int
_userAmount;
protected
void
Page_Load(
object
sender, EventArgs e)
{
_sessionId = Guid.Parse(HttpContext.Current.Session[
"BWSESSION"
].ToString());
try
{
if
(PortalApplication ==
null
)
return
;
Features =
new
Features(PortalApplication.User);
if
(!Features.ReadUsers)
{
PortalApplication.ExecuteCommand(PortalApplication.GetAfterErrorCommand(404));
return
;
}
if
(!IsPostBack)
FillRptUsers();
AddUserHyperLink.NavigateUrl = PortalApplication.GetUrl(PortalApplication.GetCommandByName(ApplicationCommands.UserAdd).Url);
}
catch
(Exception ex)
{
PortalApplication.HandleException(ex);
ShowFailureText();
}
}
public
void
FillRptUsers()
{
var serviceProviderId = PortalApplication.User.serviceProviderId;
var groupId = PortalApplication.User.groupId;
var userResponse = PortalApplication.GetGroupUsers(serviceProviderId, groupId, UserFilter.Text, CurrentPage, (CurrentPage - 1) * PageSize, PageSize);
var users = userResponse.Item1;
_userAmount = userResponse.Item2;
if
((
string
) ViewState[
"SortOrder"
] == KeyConstants.AscSortOrder)
switch
((
string
)ViewState[
"SortColumn"
])
{
case
KeyConstants.UserNameColumn:
users = users.OrderBy(x => x.firstName).ThenBy(x => x.lastName).ToList();
break
;
case
KeyConstants.UserPhoneNumberColumn:
users = users.OrderBy(x => x.phoneNumber).ToList();
break
;
case
KeyConstants.UserInternalNumberColumn:
users = users.OrderBy(x => x.extension).ToList();
break
;
case
KeyConstants.UserLocationColumn:
users = users.OrderBy(x => x.departmentFullPath).ToList();
break
;
case
KeyConstants.UserEmailColumn:
users = users.OrderBy(x => x.emailAddress).ToList();
break
;
case
KeyConstants.UserQueueColumn:
users = users.OrderBy(x => x.hasCallQueueService).ToList();
break
;
}
else
if
((
string
) ViewState[
"SortOrder"
] == KeyConstants.DescSortOrder)
switch
((
string
)ViewState[
"SortColumn"
])
{
case
KeyConstants.UserNameColumn:
users = users.OrderByDescending(x => x.firstName).ThenByDescending(x => x.lastName).ToList();
break
;
case
KeyConstants.UserPhoneNumberColumn:
users = users.OrderByDescending(x => x.phoneNumber).ToList();
break
;
case
KeyConstants.UserInternalNumberColumn:
users = users.OrderByDescending(x => x.extension).ToList();
break
;
case
KeyConstants.UserLocationColumn:
users = users.OrderByDescending(x => x.departmentFullPath).ToList();
break
;
case
KeyConstants.UserEmailColumn:
users = users.OrderByDescending(x => x.emailAddress).ToList();
break
;
case
KeyConstants.UserQueueColumn:
users = users.OrderByDescending(x => x.hasCallQueueService).ToList();
break
;
}
else
users = users.OrderBy(x => x.firstName).ThenBy(x => x.lastName).ToList();
// Consistant numbers:
foreach
(var user
in
users)
user.phoneNumber = CompleetApplication.E164ToLocal(user.phoneNumber);
var dataSource =
new
PagedDataSource
{
DataSource = users,
AllowPaging =
true
,
PageSize = PageSize
};
if
(CurrentPage > dataSource.PageCount - 1)
dataSource.CurrentPageIndex = CurrentPage - 1;
rptUsers.DataSource = dataSource;
rptUsers.DataBind();
//nieuw
_pageCount = dataSource.PageCount;
//_pageCount = (userResponse.Item2/10) + 1;
// tiill here
SetPageControl(dataSource);
}
public
void
SetPageControl(PagedDataSource dataSource)
{
var currentPageLabel = (Label)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl(
"currentPageLabel"
);
var nextPageButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl(
"nextButton"
);
var prevPageButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl(
"prevButton"
);
var prevThreePagesButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl(
"prevThreePagesButton"
);
var nextThreePagesButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl(
"nextThreePagesButton"
);
var firstPageButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl(
"firstPageButton"
);
var lastPageButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl(
"lastPageButton"
);
var currentPageOfTotalPagesLabel = (Label)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl(
"CurrentPageOfTotalPagesLabel"
);
nextPageButton.Visible =
true
;
prevPageButton.Visible =
true
;
prevThreePagesButton.Visible =
true
;
nextThreePagesButton.Visible =
true
;
firstPageButton.Visible =
true
;
lastPageButton.Visible =
true
;
currentPageLabel.Text = (CurrentPage + 1).ToString();
if
(Convert.ToInt32(currentPageLabel.Text) == _pageCount)
currentPageLabel.Text = CurrentPage.ToString();
// shows current page of total pages
currentPageOfTotalPagesLabel.Text = $
"Page {currentPageLabel.Text} of {_pageCount}, items {(CurrentPage * 10) + 1}-"
+ $
"{(CurrentPage * 10) + 10} of {_userAmount}"
;
if
(CurrentPage + 1 >= dataSource.PageCount)
{
nextPageButton.Visible =
false
;
nextThreePagesButton.Visible =
false
;
lastPageButton.Visible =
false
;
}
if
(CurrentPage == 0)
{
prevPageButton.Enabled =
false
;
prevPageButton.Text =
" "
;
prevPageButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BackgroundColor,
"transparent"
);
prevPageButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BorderWidth,
"0"
);
prevThreePagesButton.Enabled =
false
;
prevThreePagesButton.Text =
" "
;
prevThreePagesButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BackgroundColor,
"transparent"
);
prevThreePagesButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BorderWidth,
"0"
);
firstPageButton.Enabled =
false
;
firstPageButton.Text =
" "
;
firstPageButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BackgroundColor,
"transparent"
);
firstPageButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BorderWidth,
"0"
);
}
if
(dataSource.PageCount == 1)
{
// old
//prevPageButton.Visible = false;
//currentPageLabel.Visible = false;
//nextPageButton.Visible = false;
//prevThreePagesButton.Visible = false;
//nextThreePagesButton.Visible = false;
//firstPageButton.Visible = false;
//lastPageButton.Visible = false;
// nieuw
prevPageButton.Visible =
true
;
currentPageLabel.Visible =
true
;
nextPageButton.Visible =
true
;
prevThreePagesButton.Visible =
true
;
nextThreePagesButton.Visible =
true
;
firstPageButton.Visible =
true
;
lastPageButton.Visible =
true
;
}
}
public
int
CurrentPage
{
get
{
var o = ViewState[
"_CurrentPage"
];
if
(o ==
null
)
return
0;
return
(
int
)o;
}
set
{
ViewState[
"_CurrentPage"
] = value;
}
}
protected
void
prevButton_Click(
object
sender, EventArgs e)
{
CurrentPage -= 1;
FillRptUsers();
}
protected
void
prevThreePagesButton_Click(
object
sender, EventArgs e)
{
CurrentPage -= 3;
FillRptUsers();
}
protected
void
firstPageButton_Click(
object
sender, EventArgs e)
{
CurrentPage = 0;
FillRptUsers();
}
protected
void
nextButton_Click(
object
sender, EventArgs e)
{
CurrentPage += 1;
FillRptUsers();
}
protected
void
nextThreePagesButton_Click(
object
sender, EventArgs e)
{
CurrentPage += 3;
FillRptUsers();
}
protected
void
lastPageButton_Click(
object
sender, EventArgs e)
{
CurrentPage =_pageCount;
FillRptUsers();
}
}
Reply
Answers (
1
)
Accessing File From Directory In Asp.net
What is the Maximum size of Max Pool Size in iis web.config?