Answered by:
how to hide previous link in datapager

Question
-
User-535616387 posted
Hi guys,
i have datapager paging, i want to hide the previous button "<<" when user in page 1.
please info how to hide previous button, and when user click page 2 the previous button will showing ?
below is my code :
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="lvCustomers" PageSize="3"> <Fields> <asp:NextPreviousPagerField ButtonCssClass="command" FirstPageText="« " PreviousPageText="« " RenderDisabledButtonsAsLabels="false" ShowFirstPageButton="false" ShowPreviousPageButton="true" ShowLastPageButton="false" ShowNextPageButton="false" RenderNonBreakingSpacesBetweenControls="False" /> <asp:NumericPagerField CurrentPageLabelCssClass="current" NextPreviousButtonCssClass="next" RenderNonBreakingSpacesBetweenControls="False" /> <asp:NextPreviousPagerField ButtonCssClass="command" LastPageText="›" NextPageText=" »" RenderDisabledButtonsAsLabels="false" ShowFirstPageButton="false" ShowPreviousPageButton="false" ShowLastPageButton="false" ShowNextPageButton="true" RenderNonBreakingSpacesBetweenControls="False" /> </Fields> </asp:DataPager>
Thanks & Best Regards.
Wibowo WiwitMonday, February 19, 2018 10:33 AM
Answers
-
User541108374 posted
Hi,
in the ondatabound event you can figure out on which page you currently are. If it's the first page then state something like:
DataPager1.NextPreviousPagerField.ShowPreviousPageButton = false;
It could be that you need to perform a findcontrol to get to the nextpreviouspagerfield of DataPager1 before you can set this setting.
Kris.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, February 19, 2018 10:53 AM -
User-1716253493 posted
Protected Sub DataPager1_PreRender(sender As Object, e As EventArgs) Dim DP1 As DataPager = CType(sender, DataPager) For Each c As Control In DP1.Controls For Each c2 As Control In c.Controls If TypeOf c2 Is Button Then Dim btn As Button = CType(c2, Button) If Not btn.Enabled Then btn.Attributes("style") = "display:none;" End If End If Next Next End Sub
or
Protected Sub DataPager1_PreRender(sender As Object, e As EventArgs) Dim DP1 As DataPager = CType(sender, DataPager) For Each c As Control In DP1.Controls For Each c2 As Control In c.Controls If TypeOf c2 Is Button Then Dim btn As Button = CType(c2, Button) btn.Visible = btn.Enabled End If Next Next End Sub
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, February 20, 2018 3:12 AM -
User-1716253493 posted
if you want specific button only
If Not btn.Enabled And btn.Text = "<< " Then btn.Attributes("style") = "display:none;" End If
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, February 20, 2018 3:33 AM
All replies
-
User541108374 posted
Hi,
in the ondatabound event you can figure out on which page you currently are. If it's the first page then state something like:
DataPager1.NextPreviousPagerField.ShowPreviousPageButton = false;
It could be that you need to perform a findcontrol to get to the nextpreviouspagerfield of DataPager1 before you can set this setting.
Kris.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, February 19, 2018 10:53 AM -
User-1716253493 posted
Protected Sub DataPager1_PreRender(sender As Object, e As EventArgs) Dim DP1 As DataPager = CType(sender, DataPager) For Each c As Control In DP1.Controls For Each c2 As Control In c.Controls If TypeOf c2 Is Button Then Dim btn As Button = CType(c2, Button) If Not btn.Enabled Then btn.Attributes("style") = "display:none;" End If End If Next Next End Sub
or
Protected Sub DataPager1_PreRender(sender As Object, e As EventArgs) Dim DP1 As DataPager = CType(sender, DataPager) For Each c As Control In DP1.Controls For Each c2 As Control In c.Controls If TypeOf c2 Is Button Then Dim btn As Button = CType(c2, Button) btn.Visible = btn.Enabled End If Next Next End Sub
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, February 20, 2018 3:12 AM -
User-1716253493 posted
if you want specific button only
If Not btn.Enabled And btn.Text = "<< " Then btn.Attributes("style") = "display:none;" End If
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, February 20, 2018 3:33 AM -
User-535616387 posted
Thank You mas Bro Oned GK & XII_II
Friday, February 23, 2018 7:58 AM