private void BindOtherInstances() { int? currentValue = ddlNewRegistrationInstance.SelectedValueAsInt(); // list other registration instances using ( var rockContext = new RockContext() ) { var otherRegistrationInstances = new RegistrationInstanceService( rockContext ).Queryable() .Where( i => i.RegistrationTemplateId == Registration.RegistrationInstance.RegistrationTemplateId && i.Id != Registration.RegistrationInstanceId ); if ( !cbShowAll.Checked ) { otherRegistrationInstances = otherRegistrationInstances .Where( i => i.IsActive == true && ( i.EndDateTime >= RockDateTime.Now || i.EndDateTime == null ) ); } var instances = otherRegistrationInstances .Select( i => new { Value = i.Id, Text = i.Name } ) .ToList(); ddlNewRegistrationInstance.DataSource = instances; ddlNewRegistrationInstance.DataBind(); ddlNewRegistrationInstance.Items.Insert( 0, new ListItem( String.Empty, String.Empty ) ); ddlNewRegistrationInstance.SetValue( currentValue ); } }