in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

rcragg's blog

Why is SPListItem always ReadOnly?

Dim targetWeb As SPWeb = SPControl.GetContextWeb(Context).Webs.Item("sites/IT")
Dim docLib As SPDocumentLibrary = CType(targetWeb.Lists.Item(New Guid(targetFolderGUID)), SPDocumentLibrary)
Dim docLibFile As SPFile = docLib.RootFolder.Files.Add(fileName, fileContents)
Dim docItem As SPListItem = docLibFile.Item
docItem.Fields("Category") = "General"

If I attempt to set the value of a field (i.e. a Column) in a List, the complier complains that:

Property 'Item' is 'ReadOnly'

Anyone know why I shouldnt be allowed to do it this way?!


UPDATE: the following code is what I was looking for...

docItem("Category") = "General"
docItem.Update()

Comments

No Comments

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts