title: C# Failed to change {name} property of user control
body: <p>When I tried to change the {name} property of the user controls on the form, the below error occurs:</p>
  
  <p><img src="https://i.stack.imgur.com/ec8ie.png" alt="enter image description here"></p>
  
  <p>And here's the "selectedVal" property on "ddlPriority" user control
  <img src="https://i.stack.imgur.com/dGBLa.png" alt="enter image description here"></p>
  
  <p>Here's the ddlPriority_Load function</p>
  
  <pre><code>  Scheduler.DAL.TableClass.Priority pri = new Scheduler.DAL.TableClass.Priority();
              combxPriority.DataSource = pri.selectPriorities();
              combxPriority.DisplayMember = "name";
              combxPriority.ValueMember = "PriorityID";
              Scheduler.DAL.TableClass.Settings set = new Scheduler.DAL.TableClass.Settings();
              if (set.thisTable != null)
                  combxPriority.SelectedValue = set.thisTable.DefaultPriorityID;
  </code></pre>
  
  <p>The ddlPriority user control is just a combo box.</p>
  
  <p>How can I solve this problem?</p>
  
  <hr>
  
  <p>Edited:</p>
  
  <p>Below is the selectPriorities method:</p>
  
  <p>properties.cs</p>
  
  <pre><code>public static string DBConnection = ConfigurationSettings.AppSettings["DB_Connection"];
  </code></pre>
  
  <p>Priority.cs</p>
  
  <pre><code>public DataTable selectPriorities()
          {
              SqlConnection con = new SqlConnection(properties.DBConnection);
              con.Open();
              string sqlQuery = "select name, PriorityID from Priority";
              DataTable dt = new DataTable();
              SqlCommand cmd = new SqlCommand(sqlQuery, con);
              SqlDataReader read = cmd.ExecuteNonQuery();
              dt.Load(read);
              read.Close();
              con.Close();
              return dt;
          }
  </code></pre>