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.