SharePoint中删除列表记录

方法1:

SPList spListQuestion = spWeb.Lists["Question List"];

for (int i = spListQuestion.Items.Count - 1; i >= 0; i--)

{ spListQuestion.Items[i].Delete(); }

方法2:

SPList spListQuestion = spWeb.Lists["Question List"];

string sDIDTitle = spListQuestion.Fields["DID"].InternalName;

SPQuery spQuery = new SPQuery();

spQuery.Query = "" + "" + spDocItem.ID.ToString() + "";

SPListItemCollection collListItems = spListQuestion.GetItems(spQuery);

for (int i = 0; i < collListItems.Count; i++)

{ string ID = collListItems[i]["ID"].ToString();

SPItem spItem = spListQuestion.GetItemById(Int16.Parse(ID));

spItem.Delete();

 }

posted on 2010-12-22 11:02  catvi  阅读(427)  评论(0编辑  收藏  举报

导航