Fengzhimei@Dot.Net
Designing My Colorful Dream

Hi,all

I want to know how can i change the spfolder's sort number in sharepoint by using object model.
And i do it like this,but there is a exception:
/////////////////////////////////////////////////
SPWeb spWeb = this.DocLib.GetWeb();//get SPWeb object(the DocLib is the DocumentLibrary instance)
spWeb.AllowUnsafeUpdates = true;
SPFolder spFolder = spWeb.GetFolder(this.strFolderURI);//get a specifically SPFolder object

SPQuery query = new SPQuery();
query.Folder = spFolder;//specify the SPFolder i want to query
query.Query = "<Where><Eq><FieldRef Name='FSObjType'/><Value Type='Lookup'>1</Value></Eq></Where>";
SPListItemCollection spListItemCollection = this.DocLib.docLibrary.GetItems(query);//get all subfolders of a specifically SPFolder
//loop for change the SPFolder's order field
for (int i=0;i<spListItemCollection.Count;i++)
{
//Response.Write(spListItemCollection[i].Fields.GetField("Order").ReadOnlyField);
spListItemCollection[i]["Order"] = "100";//there will be throw a exception
spListItemCollection[i].Update();
//Response.Write(spListItemCollection[i]["Order"]+"<br>");
}//end for
/////////////////////////////////////////////////
And the SPListItem's "Order" field is not a ReadOnlyField.
I don't know what happened,would you like to help me,thanks in advance!

posted on 2004-04-16 18:05  fengzhimei  阅读(847)  评论(0编辑  收藏  举报