SharePoint of the Day #34

If you are working with Lookup columns you can cast the list item values into SPFieldLookupValue objects to retrieve the individual properties:
SPFieldLookupValue value = new SPFieldLookupValue(item["LookupColumn"].ToString());
int lookupID = value.LookupId;
string lookupValue = value.LookupValue;
Delicious Digg This Post

Posted under Developer

This post was written by spotd on May 18, 2009

Tags:

SharePoint of the Day #32

If you need a collection containing both list items and list folders, pass an SPQuery to the SPList.GetItems method. On the SPQuery object, set the ViewAttributes to “Scope=RecursiveAll” to get both folders and items from a list:
SPQuery q = new SPQuery();
q.ViewAttributes = “Scope=\”RecursiveAll\””;
SPListItemCollection listItems = list.GetItems(q);
Delicious Digg This Post

Posted under Developer

This post was written by spotd on May 14, 2009

Tags:

SharePoint of the Day #31

You cannot create a LookupColumn through CAML code alone, since you need to know the list GUID of the list to which the Lookup column will refer.
However, you can use a feature receiver to set up the Lookup column on activation by looking up the correct list GUID at that time.
Delicious Digg [...]

Posted under Developer

This post was written by spotd on May 13, 2009

Tags:

SharePoint of the Day #29

You can only Cancel an -ing type event, for example ItemAdding or ItemUpdating, but not the -ed type events. To cancel an item event, set SPItemEventProperties.Cancel to true. You will get the correct SPItemEventProperties object as a parameter to the method call.
Delicious Digg This Post

Posted under Developer

This post was written by spotd on May 11, 2009

Tags:

SharePoint of the Day #28

You can create more elaborate CustomAction elements by letting an assembly and a class handle the creation of the CustomAction. To do so, set the ControlAssembly and ControlClass of the CustomAction element. You can also use a .ascx user control by setting the ControlSrc attribute.
For example, you can add a menu tree to the [...]

Posted under Developer

This post was written by spotd on May 8, 2009

Tags:

SharePoint of the Day #27

A lot of the visual interface of SharePoint is contained in RenderingTemplate controls, stored in the [12]\TEMPLATE\CONTROLTEMPLATES\DefaultTemplates.ascx.
You can override these rendering templates by creating your own .ascx files in the CONTROLTEMPLATES folder by adding RenderingTemplate controls with the same ID as the template you wish to override.
Note that you can only override once, and that [...]

Posted under Administrator, Developer

This post was written by spotd on May 7, 2009

Tags:

SharePoint of the Day #26

The deleted items of a site collection or site is stored in the RecycleBin collection in the form of RecycleBinItem items. You can query or manipulate these items, for example using the following code:
SPWeb web = SPContext.Current.Web;
foreach (SPRecycleBinItem item in web.RecycleBin)
{
item.Restore();
}
Delicious Digg This Post

Posted under Developer

This post was written by spotd on May 6, 2009

Tags:

SharePoint of the Day #24

You can cast item values into a more manageable type if you know the base field type. For example, cast SPListItem["url"] into a SPFieldUrlValue object to access the Url and Description as named properties:
SPFieldUrlValue v = item["Url"];
string url = v.Url;
string description = v.Description;
Delicious Digg This Post

Posted under Developer

This post was written by spotd on May 4, 2009

Tags:

SharePoint of the Day #23

You can add event receivers to SharePoint objects using the object model. Any object that supports even receivers has an EventReceivers collection to which you can Add() new receivers.
If you want to add event receivers to specific list instances or content type instances, for example, you must use the object model.
Delicious Digg [...]

Posted under Developer

This post was written by spotd on May 1, 2009

Tags:

SharePoint of the Day #22

When you are adding a FieldRef element to your content type you can override whether the column is shown in edit and new forms by setting the ShowInEditForm and ShowInNewForm.
However, setting the ShowInDisplayForm does not work.
You can learn more about content types in USP Journal Volume 1, Issue 2
Delicious Digg This [...]

Posted under Developer

This post was written by spotd on April 30, 2009

Tags: