The Training Course List

After you define the content types, you can create lists that display those content types. Lists are containers of rows and columns; they 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 Contoso.TrainingManagement project, point to Add, and then click New Item.
  2. In the Categories pane, click SharePoint. In the Templates pane, click List Definition from Content Type.
  3. In the Name text box, type the name of the list, and then click Add.
  4. In the List Definition Type drop-down box, click 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

The next sections describe these files.

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 field reference 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.

Home page on MSDN | Community site