title: check if a values has been selected from dropdown in c#
body: <p>I have 3 dropdown boxes (combo box) in asp.net environment.
  They are all optional, so if a user has selected anything, i am updating database, if nothing has been selected at all, i am still updating database with null values.</p>
  
  <p>I tried to do this: </p>
  
  <pre><code> int? CountryId = Convert.ToInt32(ddCountries.SelectedItem.Value);
  </code></pre>
  
  <p>I was hoping that if nothing is selected null will be inserted in CountryId, but, instead its throwing an exception.</p>
  
  <p>I tried to search for ddCountries.isSelected (or something like that) but it obviously doesnt exist.. </p>
  
  <p>so how do I find out if a selection has been made on a dropdown box? - through c# code.</p>
  
  <p>Many Thanks</p>
  
  <p>ps: I have a thought - i put each dropdown box in a try... catch block and if exception arises, set variables to null manually.. but I am not sure thats the best way to do it!</p>