您的位置:首页 > 产品设计 > UI/UE

How to get the value of one specified item

2012-06-16 10:52 519 查看
Method1: public override void ItemAdding(SPItemEventProperties properties)
{
base.ItemAdding(properties);

//Get the current web where event occurred
SPWeb webSite = properties.Web;
//Get the list in current web by displayed name
SPList documents = webSite.Lists["Documents"];

//the GetItems() method to return multiple list items
SPListItemCollection itemCollection = documents.GetItems();
//use a loop and conditional structures to select the item you want
SPListItem item = null;
foreach (SPListItem it in itemCollection)
{
if (it.Name == "Lab.docx") //Note that the file name has suffix
{
item = it;
}
}

//After you have a reference to the list item that you want, your code can read the value of any field by using an identity of the SPListItem object
string title=(string)item["Title"];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: