The Training Course List

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

After you define the content types, you can create lists that display those content types. Lists are containers made up of rows and columns and are similar to database tables. The SharePoint platform provides interfaces to manage lists that are very easy to use. In many situations, lists are preferable to databases because, unlike many relational database management systems, they require no specialized knowledge. Because of the simplicity of lists, the Training Management application uses them as the primary method of storing data. For more information about when to use lists and databases, see Using SharePoint Lists VS. Database Tables. SharePoint lists are instances of the SPList class. For more information, see SPList Class (Microsoft.SharePoint) on MSDN.

The Training Management application uses a list to display the available training courses. This list is based on the TrainingCourse content type. If you use Visual Studio extensions for Windows SharePoint Services, you supply only a pre-existing content type to create this list. The following procedure demonstrates how to create a list that is based on a content type.

To create a list definition from a content type

  1. In Visual Studio, right-click the site definition project. This project is named Contoso.TrainingManagement.
  2. Point to Add, and then click New Item.
  3. In the Categories pane, select SharePoint. In the Templates pane, select List Definition from Content Type.
  4. In the Name text box, type the name of the list, and then click Add.
  5. In the List Definition Type drop-down box, select the content type. If you want to create an instance of the list, select the check box. Click OK.

Visual Studio generates three XML files when it creates a list. For the TrainingCoursesListDefinition in the Training Management application, the following are the names of the XML files:

  • Schema.xml
  • TrainingCourseListInstance.xml
  • TrainingCourseListTemplate.xml

These files are discussed in the following sections.

The Schema File

The Schema.xml file defines the views, forms, toolbar, and special fields for lists that are created with the List Definition template. The schema is used wherever the associated SPList instance occurs. It includes definitions of two views that are identified as BaseViewID=0 and BaseViewID=1. The Trainingdashboard.aspx page uses BaseViewID=0. The page where users can create a course uses BaseViewID=1. The ViewFields element defines the field references that appear on the list page. This is shown in the following XML.

<ViewFields>
    ...
    <FieldRef Name="TrainingCourseCode">
    </FieldRef>
    <FieldRef Name="TrainingCourseEnrollmentDate">
    </FieldRef>
    <FieldRef Name="TrainingCourseStartDate">
    </FieldRef>
    <FieldRef Name="TrainingCourseEndDate">
    </FieldRef>
    <FieldRef Name="TrainingCourseCost">
    </FieldRef>
    <FieldRef Name="TrainingCourseDifficultyLevel">
    </FieldRef>
</ViewFields> 

Each of the field references is associated with a field that is also included in the schema file. Each field has a variety of attributes associated with it, including Name, which is the name that appears as one of the categories on the Training Courses list view. For example, the TrainingCourseCode field has a display name of Code.

The List Template File

The TrainingCourseListTemplate.xml file is the template for the training course list instances.

The List Instance File

The TrainingCourseListInstance.xml file defines a feature ID that establishes a deployment dependency. This means that an instance of the Training Course list appears when you create a site based on a site definition that has the feature referenced by the feature ID.

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Show: