通过
SPQuery
获得
Score
字段中大于等于
60
的列表条目,并且在这些条目的标题后加上“(合格)”字符串,然后再另一列表中,添加一个新条目,写入合格人数。
//
首先获取到SPWeb对象web
SPListCollection lists = web.Lists;
SPList scoreList = lists[ " Score " ];
SPList passList = lists[ " Pass " ];
SPQuery query = new SPQuery();
query.Query = " <Where><Geq><FieldRef Name='Score'/> " +
" <Value Type='Number'>60</Value></Geq></Where> " ;
SPListItemCollection items = scoreList.GetItems(query);
foreach (SPListItem item in items)
{
string title = item["Title"] + "(合格)";
item["Title"] = title;
item.Update();
}
SPListItem newItem = passList.Items.Add();
newItem[ " Count " ] = items.Count;
newItem.Update();
SPListCollection lists = web.Lists;
SPList scoreList = lists[ " Score " ];
SPList passList = lists[ " Pass " ];
SPQuery query = new SPQuery();
query.Query = " <Where><Geq><FieldRef Name='Score'/> " +
" <Value Type='Number'>60</Value></Geq></Where> " ;
SPListItemCollection items = scoreList.GetItems(query);
foreach (SPListItem item in items)
{
string title = item["Title"] + "(合格)";
item["Title"] = title;
item.Update();
}
SPListItem newItem = passList.Items.Add();
newItem[ " Count " ] = items.Count;
newItem.Update();
本文转自永春博客园博客,原文链接:http://www.cnblogs.com/firstyi/archive/2007/12/04/981978.html,如需转载请自行联系原作者