title: How to assign my custom permission level to my TestGroup?
body: <p>I have created one group Name: TestGroup 
  and one permission level Name: Custompermisionlevel</p>
  
  <p>How can I assign the permission level(Custompermisionlevel) to my group programmatically?</p>
  
  <p>I'm using this code:</p>
  
  <pre><code>public void SetPermissionsToGroup()
      {
          using (var site = new SPSite("http://sp2010:8888"))
          {
              using (var web = site.OpenWeb())
              {
                  //Get group and group roles
                  var group = web.SiteGroups["TestGroup"];
                  var roles = new SPRoleAssignment(group);                   
  
                  //Add another role
                  roles.RoleDefinitionBindings.Add(web.RoleDefinitions.GetByType(SPRoleType.Custompermisionlevel));
                  roles.Update();
              }
          }
      }
  </code></pre>
  
  <p>I am not getting my Custompermisionlevel in SPRoleType. Does anyone know what I am doing wrong?</p>
  
  <p>getting this error:Cannot update a permission level assignment that is not part of a permission level assignment collection.</p>