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
70.5k
How to add pagination like google ?
Mar 23 2017 6:57 AM
HI,
ive got the following repeater but how can i add paginanion like google because the old one isn't woking properly.
<div
class
=
"content last"
>
<asp:Repeater ID=
"rptUsers"
runat=
"server"
>
<HeaderTemplate>
<table style=
"width: 100%;"
>
<thead>
<tr>
<th
class
=
"column-xxxl"
>
<asp:LinkButton ID=
"sortNameLink"
CssClass=
'<%# GetSortArrowCssClass(KeyConstants.UserNameColumn) %>'
runat=
"server"
OnClick=
"SortColumn_Click"
>Naam</asp:LinkButton>
</th>
<th
class
=
"column-xl"
>
<asp:LinkButton ID=
"sortPhoneNumberLink"
CssClass=
'<%# GetSortArrowCssClass(KeyConstants.UserPhoneNumberColumn) %>'
runat=
"server"
OnClick=
"SortColumn_Click"
>Telefoonnummer</asp:LinkButton>
</th>
<th
class
=
"column-l"
>
<asp:LinkButton ID=
"sortInternalNumberLink"
CssClass=
'<%# GetSortArrowCssClass(KeyConstants.UserInternalNumberColumn) %>'
runat=
"server"
OnClick=
"SortColumn_Click"
>Intern Nummer</asp:LinkButton>
</th>
<%
if
(Features.Locations)
{
%>
<th
class
=
"column-l"
>
<asp:LinkButton ID=
"sortLocationLink"
CssClass=
'<%# GetSortArrowCssClass(KeyConstants.UserLocationColumn) %>'
runat=
"server"
OnClick=
"SortColumn_Click"
>Afdeling</asp:LinkButton>
</th>
<% } %>
<th
class
=
"column-xxxl"
>
<asp:LinkButton ID=
"sortEmailLink"
CssClass=
'<%# GetSortArrowCssClass(KeyConstants.UserEmailColumn) %>'
runat=
"server"
OnClick=
"SortColumn_Click"
>Email</asp:LinkButton>
</th>
<th
class
=
"column-s"
style=
"text-align: center;"
>
<asp:LinkButton ID=
"sortQueueLink"
CssClass=
'<%# GetSortArrowCssClass(KeyConstants.UserQueueColumn) %>'
runat=
"server"
OnClick=
"SortColumn_Click"
>Wachtrij</asp:LinkButton>
</th>
<%
if
(Features !=
null
&& Features.DeleteUsers)
{ %>
<th
class
=
"column-xxs"
style=
"text-align: center;"
>
</th>
<% } %>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:HyperLink ID=
"phoneManagementHyperLink"
runat=
"server"
Text=
'<%# (Container.DataItem as WcfUser).firstName + " " + (Container.DataItem as WcfUser).lastName%>'
NavigateUrl=
'<%#PortalApplication.GetUrl(PortalApplication.GetCommandByName(ApplicationCommands.UserEdit).Url)+string.Format("?userId={0}", (Container.DataItem as WcfUser).userId)%>'
/>
</td>
<td>
<%# (Container.DataItem
as
WcfUser).phoneNumber%>
</td>
<td>
<%# (Container.DataItem
as
WcfUser).extension%>
</td>
<%
if
(Features !=
null
&& Features.Locations)
{
%>
<td>
<%# (Container.DataItem
as
WcfUser).departmentFullPath%>
</td>
<% } %>
<td>
<%# (Container.DataItem
as
WcfUser).emailAddress%>
</td>
<td>
<div
class
=
'icon-16 active read-only check'
style=
'<%# (Container.DataItem as WcfUser).hasCallQueueService ? "margin: 0 auto;": "display:none;" %>'
></div>
</td>
<%
if
(Features !=
null
&& Features.DeleteUsers)
{ %>
<td
class
=
"column-controls"
>
<asp:Button ID=
"deleteUserButton"
runat=
"server"
CommandName=
"Gebruiker Verwijderen"
OnClientClick=
"return confirm('Weet u zeker dat u deze gebruiker wilt verwijderen?')"
CssClass=
"icon-16 bin"
OnClick=
"DeleteUserButton_Click"
CommandArgument=
"<%# (Container.DataItem as WcfUser).userId %>"
/>
</td>
<% } %>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
<div style=
"margin: 5px auto; width: 450px;"
>
<asp:Button ID=
"firstPageButton"
runat=
"server"
Text=
" First "
OnClick=
"firstPageButton_Click"
CssClass=
"button-s"
/>
<asp:Button ID=
"prevThreePagesButton"
runat=
"server"
Text=
" <<< "
OnClick=
"prevThreePagesButton_Click"
CssClass=
"button-s"
/>
<asp:Button ID=
"prevButton"
runat=
"server"
Text=
" < "
OnClick=
"prevButton_Click"
CssClass=
"button-s"
/>
<asp:Label ID=
"currentPageLabel"
runat=
"server"
CssClass=
"label label-xxs"
Style=
"text-align: center;"
/>
<asp:Button ID=
"nextButton"
runat=
"server"
Text=
" > "
OnClick=
"nextButton_Click"
CssClass=
"button-s"
/>
<asp:Button ID=
"nextThreePagesButton"
runat=
"server"
Text=
" >>> "
OnClick=
"nextThreePagesButton_Click"
CssClass=
"button-s"
/>
<asp:Button ID=
"lastPageButton"
runat=
"server"
Text=
" Last "
OnClick=
"lastPageButton_Click"
CssClass=
"button-s"
/>
</div>
<div>
<asp:Label ID=
"CurrentPageOfTotalPagesLabel"
Visible=
"True"
runat=
"server"
CssClass=
"label label-xxl"
Style=
"text-align: right; float: right"
/>
</div>
</FooterTemplate>
</asp:Repeater>
<div
class
=
"row error"
>
<asp:Literal ID=
"FailureTextLiteral"
runat=
"server"
EnableViewState=
"False"
/>
</div>
</div>
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()
{
//trim filter
char
[] charsToTrim = {
' '
,
'\t'
};
UserFilter.Text = UserFilter.Text.Trim(charsToTrim);
// set start index
var startIndex = PageSize*CurrentPage;
// Get sortingmethod and SortingColumn
var sorthingMethod = (
string
) ViewState[
"SortOrder"
];
var sorthingColumn = (
string
) ViewState[
"SortColumn"
];
if
(
string
.IsNullOrEmpty(sorthingMethod))
sorthingMethod =
"Asc"
;
if
(
string
.IsNullOrEmpty(sorthingColumn))
sorthingColumn =
"Name"
;
var serviceProviderId = PortalApplication.User.serviceProviderId;
var groupId = PortalApplication.User.groupId;
var userResponse = PortalApplication.GetGroupUsers(
serviceProviderId: serviceProviderId,
groupId: groupId,
filter: UserFilter.Text,
curPage: CurrentPage,
startIndex: startIndex,
limit: PageSize,
sortOrder: sorthingMethod,
sortColumn: sorthingColumn
);
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,
VirtualCount = _userAmount
};
rptUsers.DataSource = dataSource;
rptUsers.DataBind();
_pageCount = _userAmount%PageSize == 0 ? _userAmount/PageSize : (_userAmount/PageSize) + 1;
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();
// shows current page of total pages
var itemsvalue = ((CurrentPage*10) + 10) > _userAmount ? _userAmount : (CurrentPage*10) + 10;
currentPageOfTotalPagesLabel.Text = $
"Items {(CurrentPage * 10) + 1} t/m {itemsvalue} van {_userAmount}"
;
if
(dataSource.PageCount == 1)
{
prevPageButton.Visible =
true
;
currentPageLabel.Visible =
true
;
nextPageButton.Visible =
true
;
prevThreePagesButton.Visible =
true
;
nextThreePagesButton.Visible =
true
;
firstPageButton.Visible =
true
;
lastPageButton.Visible =
true
;
}
if
(CurrentPage + 1 >= _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"
);
}
}
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 -1;
FillRptUsers();
}
Reply
Answers (
1
)
Speech to text recognition
How to Integrate windows media player in asp.net?