SharePoint List ListItem 增删改 新增 修改 删除

SharePoint List ListItem 增删改 新增 修改 删除 Posted on 2008-09-12 16:42 刘政道 阅读(1011) 评论(6)  编辑 收藏

SharePoint List ListItem 增删改 新增 修改 删除

引用

<%@ Import Namespace=”Microsoft.SharePoint” %> < %@ Import Namespace=”Microsoft.SharePoint.WebControls” %>

<%@ Import Namespace=”Microsoft.SharePoint.WebPartPages” %>

 

定义SPSite

SPSite site = new SPSite(hostUrl);

SPWeb rootweb = site.RootWeb;

修改时,这是必要的

rootweb.AllowUnsafeUpdates = true;

 

 

if (isListExist(rootweb.Lists, listTitle)==false)

      SPList list = rootweb.Lists[listTitle];

 新增

SPListItem thisitem = list.Items.Add(); thisitem["Title"] = TextBoxTitle.Text; thisitem["cParentId"] = focus;

thisitem["cId"] = maxcId.ToString();

不要忘了

thisitem.Update();

 删除

 SPListItem item = getListItemBycId(list.Items, focus); if (item != null) item.Delete();

}

 修改

SPListItem item = getListItemBycId(list.Items, focus); if (item != null) { item["Title"] = TextBoxTitle.Text; item["cUrl"] = “www.ceapet.com”; item.Update();

}

 

源代码请参考页

 http://ceapet.com/blog/?p=341

分类: SharePoint,C#
 
 
« 上一篇:SharePoint 部署WebPart时 遇到"未能加载文件或程序集"错误 » 下一篇:域帐号查询与更新
posted @ 2017-09-07 16:16  sky20080101  阅读(249)  评论(0)    收藏  举报