Question: I am trying to get the `id` of an `input field` which has a dynamic id but I get an error unrecognized expression. Below is my code : 

```
  $("#amount_paid' + data[i].patient_visit_statement_id + '").keyup(function() {
       var amount_owed = $('#amount_owed' + data[i].patient_visit_statement_id + '').val();
       var amount_paid = $('#amount_paid' + data[i].patient_visit_statement_id + '').val();
       alert('Amount owed' + amount_owed + 'Amount paid' + amount_paid + '');
       if (amount_owed < amount_paid) {
           alert('Amount to be paid exceeds amount owed');
       }
   });

```

What is the best way to get the value from the id amount\_paid which has dynamic id for each entry ?

Answer: 
Code for getting class instance values:

```
// create class instance
InstViewModel model = new InstViewModel()
{
    Uk = true,
    UkNrs = false,
};

// check all boolean fields are false or null
bool isAllNullOrFalse = (from property in typeof(InstViewModel).GetProperties()
                         let type = property.PropertyType
                         let isBool = type == typeof(bool)
                         where isBool || type == typeof(bool?)
                         let value = property.GetValue(model)
                         select value == null || (isBool && bool.Equals(value, false))).All(e => e);

Console.WriteLine("All values are null or false = {0}", isAllNullOrFalse);

```
**This is a response to the initial question - ignore this.**

When you "box" a nullable value (so you put it in an `object`), it is transformed in its underlying type (`bool` in your case) or in `null`... So if you have

```
bool? value = true;
object value2 = value; 

```

now `value2.GetType() == typeof(bool)`