wss3 sdk学习笔记一:常用对象
获得网站集对象:SPSite mySiteCollection = SPContext.Current.Site;
获得网站集下的所有网站集合对象:SPWebCollection allWebs = mySiteCollection.AllWebs;
获得网站对象:SPWeb mySite = SPContext.Current.Web;
获得网站某个列表对象:SPList myList = mySite.Lists["sharepoint故障求助"];
获得列表的项目集对象:SPListItemCollection myItems = myList.Items;
列出列表各个项目记录:
foreach (SPListItem myItem in myItems)
{
writer.Write(myItem["标题"].ToString() + " :: " +
myItem["问题"].ToString() + "<BR>");
}
{
writer.Write(myItem["标题"].ToString() + " :: " +
myItem["问题"].ToString() + "<BR>");
}
在列表中新增加一个项目:
更新某个项目的栏的值:SPListItem myNewItem = myList.Items.Add();
myNewItem["URL_Field_Name"] ="URL, Field_Description";
myNewItem.Update();
SPListItem myItem = myItems[0];
myItem["Status"]="Not Started";
myItem["Title"]="Task Title";
myItem.Update();
myItem["Status"]="Not Started";
myItem["Title"]="Task Title";
myItem.Update();