Exercise: Gridview with paging and footer for films

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

The answer to the exercise will be included and explained if you attend the Wise Owl course listed below!

Category ==> ASP.NET webforms - C#  (25 exercises)
Topic ==> Basic Gridviews  (2 exercises)
Level ==> Harder than average
Course ==> ASP.NET webforms - C#
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Create a new website, and add to it the ASP.NET files in the above folder (if you haven't already done so, you'll also need to run the SQL script to generate a database of films in SQL Server).

Create a form called frmFilmsPaged to show a paged gridview of films, with a hyperlink field and a footer (!).  Hints on how to do this are shown below:

ASP.NET 4.0 - C# exercise - Basic Gridviews (image 1)

The gridview includes paging (5 films at a time) and a hyperlink field

To get the above gridview to work you'll need to:

  • Set the PageSize property of the gridview to 5, the AllowPaging property to True, and quite a few other formatting and styling properties.
  • Set the ShowFooter property of the gridview to True (that's what gives the yellow footer)
  • Create a HyperlinkField, setting its DataNavigateUrlFields and DataNavigateUrlFormatString properties

When a user clicks on the film shown above, it should take them to the URL frmShowFilm?FilmId=189.  Don't worry at this stage that this URL doesn't exist or do anything!

When everything is working to your satisfaction, close everything down!

This page has 0 threads Add post