Feel the convenience of DataGrid to data operations (3)

xiaoxiao2021-03-06  76

Section III: Fast Page

In the second quarter, I realized that DataGrid's fast and convenient in custom appearance, this section, I learned to patch data quickly.

When we query the database, we often use a page to display all the data, but the data is displayed. Remember in the ASP, we write a page of page very troublesome, when I learned to use DataGrid to render data, I am excited, because it is as simple as data sheets.

Still open attribute generators (or modify the properties of the "Page" class), this time you know you want to choose the "paging" branch on the left. On the right, select "Allow Pack", then set the number of strips, page navigation bars, and so on. Do you think this is ok, I think so, I think so, but when I run this program, I found that there is no reaction after clicking the navigation bar. Because we have to write a few code to complete this operation.

We selected the DataGrid, then select the event tab in the tab at the top of the property window (because we want to create a flip event ", find the" pageIndexchanged "event, write the following code:

Private void DataGrid1_pageIndexchanged (Object Source, System.Web.ui.WebControls.DataGridPageChangeDeventargs E)

{

DataGrid1.currentPageIndex = E.NewpageIndex;

Bindgrid ();

}

Oh, good "long" code!

explain:

DataGrid1 It has a property called CurrentPageInde to specify the shortest page now. The "E" parameter of "PageIndexchanged" event is, you can tell Dagtagrid1 which page should be displayed.

Bindgrid () is the function I used to bind the data in the first quarter. Don't write it again, check the article in the first quarter.

It's so simple, don't believe, you try.

转载请注明原文地址:https://www.9cbs.com/read-94072.html

New Post(0)