How do I add an Event Receiver to two lists?
One must be updated when an Item is inserted in a second list.
I used public override void ItemAdding(SPItemEventProperties properties)
But what should i put in this method ?
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityGrzegorz,
What happens with Event Receivers, in the receiver in feature XML has a ListTemplateId which determines to which List template the event receiver is for... So lets say you need to add event receiver on custom list then ListTemplateId=100 or you want to add to Announcements template the ListTemplateId=104, like below:
`<Receivers ListTemplateId="100">`
Now if you attach event receiver to custom list template, the event will fire for every custom list you have in the scope! And you can identify the list in code by using properties... the SPItemEventProperties has a property called List.. which give you SPList, and you can either by GUID or Name identify the list and perform operation accordingly... What I do is create a SWITCH-CASE for different lists and perform operations according in the cases!
I hope this answered and clarify the concept of Event Receivers, you can read more over here and here
So when you have deployed the event receiver it will fire for both the lists, and you will first identify for which list it has been fired.. then code accordingly!