- Business logic
- governance
- application development
- BizTalk
- SharePoint
- database
- jQuery
- SOA
- programming
- Visual C#
- Visual Studio
- Exchange
- documents
- PHP
- services
- Microsoft Office
- customization
- Exchange server
- security
- collaboration
- .NET
- SharePoint 2010
- CA
- CodePlex
- developer
- search
- document management
- portal
- WSS
- Web development
- Web sites
- authentication
- XML
- Microsoft
- software
- policy
- MOSS
- Web Parts
- Office
- Silverlight
- tools
- sandbox
- SharePoint Service Account
- InfoPath
- ASP.NET
- Windows
- server
- architecture
- Libraries
- SharePoint administration
Sorting and Filtering Lists : Page 3
Sorting and Filtering Lists
You can sort the tasks you created earlier. As an example, you can change the sort order (see Figure 14).
You can also filter the display of the tasks you have created. For example, you might set a filter for the "Task Category," (see Figure 15,) ensuring that only the tasks in the "Software Development" category show up (see Figure 16).
Figure 16 shows the results—which displays only one task, because only that task has been assigned to the Software Development category.
Restricting Access to Lists
You can also restrict access to the lists—allowing or restricting a particular site user's access to the list. For example to restrict access, follow these steps:
- Click on Settings → List Settings
- In the Permissions and Management section, click "Permissions for this list" (see Figure 17).
You can add or remove user permissions to enable or restrict access to the list, as shown in Figure 19.
To restrict access to the individual items in a list, click the "Manage Permissions" item on the list's Edit menu, and then follow the same steps as would to restrict access to a list.
Creating Lists Programmatically
The SharePoint Object Model provides a rich set of APIs; these can be used to manipulate any SharePoint site elements, i.e., lists, documents, etc. You can create a custom list programmatically in two different ways:
- Create the list from scratch using the Object Model
- Create the list from an existing template
The following code shows how to add a list item to a custom list programmatically:
SPWeb spWeb = siteCollection.AllWebs["DevX"];
SPList spList = spWeb.Lists["DevX List"];
SPListItem spListItem = spList.Items.Add();
spListItem["Title"] = "New List Item";
spListItem.Update();
To add a list item to a custom list with an attachment, you can use the following code:
SPWeb spWeb = siteCollection.AllWebs["DevX"];
SPList spList = spWeb.Lists["DevX List"];
SPListItem spListItem = spList.Items.Add();
spListItem["Title"] = "New List Item";
SPAttachmentCollection spAttachmentCollection = item.Attachments;
spAttachmentCollection.Add(fileName, byteArrayContents);
spListItem.Update();
In the second case, you have to have a custom list template in the template gallery. A list template is one that is used to create new list instances. It typically holds the default columns, permissions, views, content types - most of the content that a list is made up of. You can use the following code to create a list using a custom list template from the gallery:
SPSite spSite = SPContext.Current.Site;
SPWeb spWeb = spSite.OpenWeb();
web.AllowUnsafeUpdates = true;
SPListTemplateCollection customListTemplates =
spSite.GetCustomListTemplates(spWeb);
SPListTemplate spListTemplate =
customListTemplates["DevXListTemplate"];
spWeb.Lists.Add("Employee_Details",
"A custom list to store employee information", spListTemplate);
web.Update();
You can also create a list using a List Template Type available in the SPListTemplateType object:
Guid listID = web.Lists.Add("DevX Custom List",
"This is a Custom List", SPListTemplateType.GenericList);
SPList spList = spWeb.Lists[listID];
In closing, lists are the building blocks of SharePoint applications. Some common SharePoint list types in addition to the task list you've seen demonstrated here include document libraries, task libraries and page libraries.







Discover how to start developing for the Android platform with this extensive guide, which provides a reference to the Android platform as well as a look at developing your first Android application. You'll explore the top 10 features for developers as well as learn design and development tips that go beyond the phone and target tablet development as well.