i have two list, i wanted to update the second list while adding a new item in first one.
i am using the following code but nothing happens.
public override void ItemAdding(SPItemEventProperties properties)
{
base.ItemAdding(properties);
string MenuList = properties.ListTitle;
if (MenuList == "Menu")
{
string mySiteUrl = "http://rizwan-pc";
using (SPSite mysiteCollection = new SPSite(mySiteUrl))
{
using (SPWeb mySite = mysiteCollection.RootWeb)
{
string title = properties.ListItem["Title"].ToString();
SPList Menu_lookUp = mySite.Lists["Menu LookUp"];
SPListItem newListItem = Menu_lookUp.Items.Add();
newListItem["Applicable"] = title;
newListItem.Update();
}
}
}
}
i wanted to copy the new item in the second list which i currently added in the first list.
any help would be great, Thanks in advance.
if you want to title of the listitem than you can try this :
its good habit to use properties in your code for get site or web :
one things is that you should use
itemaddedinstead ofitemadding. its easy to get listitem by current id.