我对SharePoint很陌生,并且已经在这个问题上工作了几天。我能够以某种方式使用ItemAdded事件接收器,但我想如果我更新列表1然后使用ItemUpdated事件接收器列表2也应该更新。 我正在努力编码部分。如何将一个列表中的项目与另一个列表链接,然后再如何更新。
答案 0 :(得分:2)
以下是“ItemAdded”事件的示例 - 您的itemupdating事件可以与此类似。在此示例中,只要新项目添加到“任务”列表中,事件接收者就会在“技能和能力”列表中添加类似项目:
// ITEM ADDED
public override void ItemAdded(SPItemEventProperties properties)
{
base.ItemAdded(properties);
try
{
String curListName = properties.ListTitle;
if (_applicableLists.Contains(curListName))
{
if (properties.ListItem.ContentType.Name == "Discussion")
{
if (curListName == "Tasks")
{
SPList saList = properties.Web.Lists["Skills & Abilities"];
SPListItem saItem = SPUtility.CreateNewDiscussion(saList, properties.ListItem["Task Text"].ToString());
SPFieldLookupValue taskLookup = new SPFieldLookupValue();
taskLookup = new SPFieldLookupValue(properties.ListItem.ID, (string)properties.AfterProperties["Task ID"]);
saItem["Task Lookup"] = taskLookup;
saItem["Title"] = properties.ListItem["Task Text"].ToString();
saItem["Body"] = "Please leave a comment by clicking the Reply link on the right of this message.";
saItem[_inStatus] = "New";
// perform the update with event firing disabled
EventFiringEnabled = false;
saItem.Update();
EventFiringEnabled = true;
}
}
}
}
catch (Exception ex)
{
// handle exception...
}
}
我还建议你查看sharepoint.stackexchange.com网站,了解SharePoint的重点。祝你好运!