Hi, I created an eventreceiver bind in a subsite list (MySource) item added. Also set the ListUrl=”subsite/lists/MySource” in Elements.xml. Am targeting to perform an insert to root site list (MyTarget) but am getting null exception error. Spent a lot of silly times…nothing makes me happy. Appreciate any thought.
public override void ItemAdded(SPItemEventProperties properties)
{using (SPSite site = new SPSite(SPContext.Current.Web.Url))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists[“MyTarget”];
web.AllowUnsafeUpdates = true;
SPListItem item = list.Items.Add();
item[“Title”] = “SUGGESTION”;
item.Update();
web.AllowUnsafeUpdates = false;}
}}