title: getting modelstate false when no value is selected from dropdown
body: <p><strong>I am having two roles in my websites</strong>:<strong>Customer and Vendor</strong></p>
  
  <p>Now when vendor is doing registeration then i am providing option for <strong>selecting category in the from of dropdownlist control</strong>.Category can be as follows:<strong>Plumber,Electrical,Tailor,Carpenter</strong> etc...</p>
  
  <p><strong>This Category are loaded in the dropdownlist from which Vendor can select appropriate category.</strong></p>
  
  <pre><code>    [Required(ErrorMessage = "Please Select City")]
      [DataMember]
      public int CategoryId { get; set; }
  </code></pre>
  
  <p>i have given radio button option for Vendor and Customer on my registration page.so if user is selecting vendor then i am displaying category dropdownlist and if user is selecting customer then i am not displaying this dropdown.</p>
  
  <p>So when user submits the form this is what i am doing on my controller:</p>
  
  <pre><code> [HttpPost]
      public  ActionResult Registration(UserDetailsModel _userDetails)
      {
         if(ModelState.IsValid)
         {
         }
         else
         {
             //Error..
         }
      }
  </code></pre>
  
  <p>My Model:</p>
  
  <pre><code>public class UserDetailsModel
      {
          [DataMember]
          public int Id { get; set; }
  
          [Required(ErrorMessage = "Please Enter Name")]
          [DataMember]
          public string Fullname { get; set; }
  
          [Required(ErrorMessage = "Please Select City")]
          [DataMember]
          public int CategoryId { get; set; }
      }
  </code></pre>
  
  <p><strong>So problem is when user is selecting customer option then i am getting modelstate as false as because categoryid will be null in case of customer(as because i am not showing category dropdown to customer)</strong>.</p>
  
  <p>So How do i resolve this??</p>
  
  <p>Any Help....</p>