Simple pagination of the gridview

Source: Internet
Author: User

Simple paging:

1. Set allowpaging = "true" for the gridview. The default value of pagesize is 10.

2. Trigger the pageindexchanging event of the gridview.

3. In the background pageindexchanging event, writeCode:

Protected   Void Grdperson_pageindexchanging ( Object Sender, gridviewpageeventargs E)
{
Grdperson. pageindex = E. newpageindex;
Bindall ();
}

 

Row deletion:

Add a delete column in The gridview: <asp: commandfield showdeletebutton = "true"/>

Triggers the rowdeleting event of the gridview, and writes the deletion code in the background rowdeleting.

Deletion prompt:

Triggers the rowdatabound event of the gridview. The background code is:

 

Code

Protected   Void Grdperson_rowdatabound ( Object Sender, gridviewroweventargs E)
{
// Bind a data row
If (E. Row. rowtype = Datacontrolrowtype. datarow)
{
If (E. Row. rowstate = Datacontrolrowstate. Normal | E. Row. rowstate = Datacontrolrowstate. Alternate)
{
(Linkbutton) E. Row. cells [ 6 ]. Controls [ 0 ]). Attributes. Add ( " Onclick " , " Javascript: Return confirm ('Are you sure you want to delete :\ "" + E. Row. cells [1]. Text + " \ " ? ') " );
}< BR >}< P>

}

displayed when no record exists in the gridview:
generally, when no data exists, the gridview is not displayed on the page. When there is no data on the Internet, the method of displaying the header looks complicated and has not been tried.

I only set the property of the gridview: emptydatatext = "sorry, no Qualified Data"

, when no data is displayed, the prompt is displayed at the position of the gridview.

Related Article

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.