Exercise: Gridivew of films, formatted, with sorting

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 ==> Relatively easy
Course ==>
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 new web page called frmFilms.aspx, and on this create a gridview to look something like this (thoughts on how to proceed are shown below):

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

Your gridview should list out for each film its name, release date and number of Oscars won

To get this to work, you'll need to:

  • Create a gridview, and set its data source to show fields from the tblFilm table in the Movies database.
  • Set the AllowSorting property of the gridview, to enable sorting.

You'll also need to set the gridview's CssClass properties as follows:

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

Here we are styling the gridview, as well as alternate rows

If you get all of this to work, you could enclose the gridview in a scrolling box by setting the enclosing div tag's overflow and height properties:

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

Better? It's annoying that the column headings scroll out of view ...

Save and close all open files, and close your website.

This page has 0 threads Add post