Click here to Skip to main content
15,944,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hii ,

I used pager control for implenting paging functionality for my repeater control ..

Now the probmel is that i want to highlight selected page number with some color .

I tried to use Jquery but that control id is not accessable ..

there is link button for paging button ..

but on Dom it gives ID as contenplaceholder1_repeater_btnPage_0 and so on ... so i am unable to attach css for that button using jquery also ..

please suggest me the trick

1 solution

Refer - Implement Paging in Repeater control in ASP.Net[^]
Repeater for pager
Below is the Repeater control for populating the Pager, since the syntax of the inline code is different in C# and VB.Net, I given their respective HTML Markups. The HTML Markup has some C# and VB.Net code to swap the CSS style classes for the Current Page and the remaining pages so that the Current Page is viewed distinguished from others.

<asp:Repeater ID="rptPager" runat="server">
        <asp:LinkButton ID="lnkPage" runat="server" Text='<%#Eval("Text") %>' CommandArgument='<%# Eval("Value") %>'
            CssClass='<%# Convert.ToBoolean(Eval("Enabled")) ? "page_enabled" : "page_disabled" %>'
            OnClick="Page_Changed" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>'></asp:LinkButton>
Share this answer
Torakami 7-Jan-14 0:30am    
i am gettig an error DataBinding: 'System.String' does not contain a property with the name 'Enabled'.
Torakami 7-Jan-14 0:33am    
This my repeater control and i made changes as per suggested

<asp:Repeater ID="repeaterPager" runat="server" OnItemCommand="repeaterPager_ItemCommand" OnItemDataBound="repeaterPager_ItemDataBound">
<table cellpadding="0" cellspacing="0" border="0" style="height: 26px;">
<tr class="Grid_Pagination">
<td>Page: </td>
<asp:LinkButton ID="btnPage" CommandName="Page"
CommandArgument="<%#Container.DataItem %>"
runat="server" CssClass='<%# Convert.ToBoolean(Eval("Enabled")) ? "page_enabled" : "page_disabled" %>' OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>'>
<%# Container.DataItem %>

Enabled in that code is actually a DataBase Table field which the author is comparing and setting the CSS accordingly. You need to apply your own logic here.
Torakami 7-Jan-14 0:47am    
i have used pageddatasource control ..
That's not the problem. Problem is you need to fetch "Enabled" field from that DataSource.
If it is not present, then it will throw the Exception.

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