Add custom page flip in the gridview!

Source: Internet
Author: User
It looks like Prev 1 2 3 4 5 6 7 8 9 next

. Aspx
<Pagertemplate>
<Div class = "pager">
<Div class = "prevbtn">
<Asp: linkbutton id = "lbprev" runat = "server" commandargument = "Prev" commandname = "page"> Prev 10 </ASP: linkbutton>
</Div>
<Div>
<Asp: linkbutton id = "lB1" runat = "server" commandargument = "Next" commandname = "page"> </ASP: linkbutton>
<Asp: linkbutton id = "LB2" runat = "server" commandargument = "Next" commandname = "page"> </ASP: linkbutton>
<Asp: linkbutton id = "lb3" runat = "server" commandargument = "Next" commandname = "page"> </ASP: linkbutton>
<Asp: linkbutton id = "lb4" runat = "server" commandargument = "Next" commandname = "page"> </ASP: linkbutton>
<Asp: linkbutton id = "lb5" runat = "server" commandargument = "Next" commandname = "page"> </ASP: linkbutton>
<Asp: linkbutton id = "lb6" runat = "server" commandargument = "Next" commandname = "page"> </ASP: linkbutton>
<Asp: linkbutton id = "lb7" runat = "server" commandargument = "Next" commandname = "page"> </ASP: linkbutton>
<Asp: linkbutton id = "lb8" runat = "server" commandargument = "Next" commandname = "page"> </ASP: linkbutton>
<Asp: linkbutton id = "lb9" runat = "server" commandargument = "Next" commandname = "page"> </ASP: linkbutton>
</Div>
<Div class = "nextbtn">
<Asp: linkbutton id = "lbnext" runat = "server" commandargument = "Next" commandname = "page"> next 10 </ASP: linkbutton>
</Div>
</Div>
</Pagertemplate>
<Pagerstyle horizontalalign = "center"/>
</Pagertemplate>

. CS
Protected void gridlist_databound (Object sender, eventargs E)
{
Gridviewrow gnavfooter = gridlist. bottompagerrow;
Linkbutton sp_in = gnavfooter. findcontrol ("lbprev") as linkbutton;
Linkbutton LBN = gnavfooter. findcontrol ("lbnext") as linkbutton;

If (gridlist. pageindex = 0)
{
HSV. Visible = false;
}

Int I;
Int icount = 0;
For (I = 1; I <10; I ++)
{
Linkbutton lB = gnavfooter. findcontrol ("LB" + I. tostring () as linkbutton;
Int J;
J = gridlist. pageindex-3;
While (j <1)
{
J ++;
}
J + = icount ++;
LB. Text = J. tostring ();
LB. commandargument = J. tostring ();
If (j> gridlist. pagecount)
{
LB. Visible = false;
}
If (j = gridlist. pageindex + 1)
{
LB. Enabled = false;
}
}

If (gridlist. pageindex = gridlist. pagecount-1)
{
LBN. Visible = false;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.