Elczar Adame's Shared Points on SharePoint


Windows SharePoint Services 3.0 is bundled with lists and libraries. A list is a collection of information, including announcement, discussion board, and calendar. A library, on the other hand, is a location on a SharePoint site where we can create, collect, update, and manage files, including document library, picture library, and form library. On top of lists and libraries is the Windows SharePoint Services object model that consists of more than few assemblies and namespaces – that can used to programmatically interact with our SharePoint site components, including SharePoint lists and libraries.

Below is the list of assemblies:


Windows SharePoint Services 3.0

Microsoft Office SharePoint Server 2007

















Another component that we need to understand before writing our first line of code is the server-side object model structure of SharePoint site allied to lists and libraries. The following table shows the SharePoint site object hierarchy in relation to the collection and objects of the Microsoft.SharePoint namespace.


Site Collection

Each SPSite object, despite its singular name, represents a set of logically related SPWeb objects commonly called a "site collection".

Top-Level Web Site / Subsites

Each site collection includes any number of SPWeb objects, and each object has members that can be used to manage a site. The Webs property returns an SPWebCollection object that represents all the subsites of a specified site, and the Lists property returns an SPListCollection object that represents all the lists in the site.


Each SPList object has members that are used to manage the list or access items in the list. The GetItems method can be used to perform queries that return specific items. The Fields property returns an SPFieldCollection object that represents all the fields, or columns, in the list, and the Items property returns an SPListItemCollection object that represents all the items, or rows, in the list.

Fields / List Items

Each SPField object has members that contain settings for the field. While each SPListItem object represents a single row in the list.

Having discussed some introductory concepts, we could now easily comprehend the following codes that programmatically insert and retrieve SharePoint list data.

Data Insertion

using (SPSite spsite = new SPSite(http://SPS01))


using (SPWeb spweb = spsite.OpenWeb())


spweb.AllowUnsafeUpdates = true;

SPList splist = spweb.Lists["Custom List"];

SPListItem splistitem = splist.Items.Add();

splistitem["Title"] = "Paul Joseph Adame";

splistitem["First_x0020_Name"] = "Luke Martin";

splistitem["Last_x0020_Name"] = "Adame";




Data Retrieval

using (SPSite spsite = new SPSite("http://SPS01"))


using (SPWeb spweb = spsite.OpenWeb())


spweb.AllowUnsafeUpdates = true;

SPSiteDataQuery spsitedataquery = new SPSiteDataQuery();

spsitedataquery.Lists = "<Lists BaseType=’0’/>";

spsitedataquery.Query = "<Where><Gt><FieldRef Name=’ID’ /><Value Type=’Number’>0</Value></Gt></Where>";

spsitedataquery.Webs = "<Webs Scope=’SiteCollection’ />";

spsitedataquery.ViewFields = "<FieldRef Name=’Title’ /><FieldRef Name=’First_x0020_Name’ /><FieldRef Name=’Last_x0020_Name’ />";

spsitedataquery.RowLimit = 10;

DataTable datatable = spweb.GetSiteData(spsitedataquery);

gvwList.DataSource = datatable;




Notice that a Collaborative Application Markup Language (CALM) is being passed to the query property of the SPSiteDataQuery. CALM is an XML-based language that is used in Windows SharePoint Services to define fields and views. In our case, we use CALM to define queries against list data. Below is the query schema:







Used within the context of a query to specify a filter.



Used within the Where element to group filters in a query for a view.



Used within the Where element to group filters in a query.



Searches for a string at the start of a column that holds Text or Note field type values.



Searches for a string anywhere within a column that holds Text or Note field type values.



Arithmetic operator that means "equal to" and is used within a query.



Arithmetic operator that means "greater than or equal to." This element can be used within a Where element in a query.



Arithmetic operator that means "greater than." This element is used similarly to the Eq and Lt elements.



Arithmetic operator that means "less than or equal to." The Leq element is used in view queries similarly to the Eq and Geq elements.



Arithmetic operator that means "less than" and is used in queries in views. This element is used similarly to the Eq and Gt elements.



Arithmetic operator that means "not equal to" and is used in queries.



Used in queries to compare the dates in a recurring event with a specified DateTime value, to determine whether they overlap.



Used within a query to return items that are not empty (Null).



Used within a query to return items that are empty (Null).



Determines the sort order for a query. The OrderBy element contains a group of FieldRef elements.



Contains a Group By section for grouping the data returned through a query in a list view.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Tag Cloud

%d bloggers like this: