title: SP2010 Attach Event Receiver to specific list programmatically - runs for all lists
body: <p>I'm attaching a event receiver to a single list (Web scope). But the ER runs for all lists in the Web. This <a href="https://stackoverflow.com/questions/4014020/how-can-i-add-event-receiver-only-for-list-with-specyfic-template-id">question</a> says that the feature, the ER is deployed in, have to be Web scope. This is the case.</p>
  
  <p>The Feature is activated programmatically bound to an ER of a list in the TLS.</p>
  
  <pre><code>newProjectWeb.Features.Add(new Guid("57e21870-6285-4e0a-b9a0-067f774492ae"));
  </code></pre>
  
  <p>Please see my code below. Am I missing an Update or anything?</p>
  
  <p>Thanks for your help in advance.</p>
  
  <pre><code>public void AddEventReceiverToMemberList()
      {
          try
          {
              _clsLists.AddEventReceiverToList(Web, ProjectMemberList.LIST_INTERNAL_NAME, typeof(SCMUProjectMemberList), SPEventReceiverType.ItemAdded);
              _clsLists.AddEventReceiverToList(Web, ProjectMemberList.LIST_INTERNAL_NAME, typeof(SCMUProjectMemberList), SPEventReceiverType.ItemDeleting);
              _clsLists.AddEventReceiverToList(Web, ProjectMemberList.LIST_INTERNAL_NAME, typeof(SCMUProjectMemberList), SPEventReceiverType.ItemUpdated);
  
              Web.Update();
          }
          catch (Exception)
          {
              throw;
          }
      }
  
  public void AddEventReceiverToList(SPWeb web, string listName, Type eventReceiverClass, SPEventReceiverType eventType)
      {
          SPList list = this.GetListByName(web, listName);            
  
          string className = eventReceiverClass.FullName;
          string assemblyName = Assembly.GetAssembly(eventReceiverClass).FullName;
  
          list.EventReceivers.Add(eventType, assemblyName, className);
      }
  </code></pre>