10.02.2014 Views

Beginning Ajax With ASP.NET (2006).pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

What Is Built into <strong>ASP</strong>.<strong>NET</strong><br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

How It Works<br />

Here you have a list of books, their descriptions, and a comment associated with each one. The GridView<br />

will render the list of books for the user to browse through. By default, sorting and paging is not enabled<br />

on the GridView control, so all the book entries are displayed on the web page. In many cases, paging is<br />

enabled to allow a smaller list of content to be displayed at any one time, but also to allow the user to<br />

advance that window or page to view more entries within the list. In this example, you have enabled<br />

paging by setting the AllowPaging property of the control to true. The GridView control also contains<br />

a PageSize property that determines how many entries are displayed per page when paging is enabled.<br />

By default this is 10, which is what this example uses.<br />

When paging is enabled, the GridView displays a paging navigation bar at the bottom of the control to<br />

allow the user to select a different page to view. By default, when a new page is selected by the user, the<br />

GridView causes a postback to occur, so that the data for the next page can be retrieved by the server.<br />

In the example, you will note that you set the EnableSortingAndPagingCallbacks property to true,<br />

and this is what is required to enable asynchronous callbacks for the GridView control. <strong>With</strong> this property<br />

enabled, each time the user clicks on the paging navigation bar to view a different page of data, no<br />

postback occurs, but rather an asynchronous callback is executed to perform this work on the server<br />

and return the results. The new page is then dynamically updated within the GridView control on<br />

the browser.<br />

It may now be more apparent why this property is not enabled by default. The EnableSortingAnd<br />

PagingCalbacks property is applicable only if paging and/or sorting is enabled within the GridView<br />

control, and this functionality is not enabled by default. Therefore, enabling the EnableSortingAnd<br />

PagingCalbacks property by default would make no sense.<br />

131

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!