title: Clear ViewModel validation Error
body: <p>I have created a <strong>ViewModel</strong> which contains other models</p>
  
  <pre><code>namespace CreatingLayout.Models
  {
      public class ViewModel
      {
          public tbl_Roles Roles { get; set; }
          public tbl_Category Category { get; set; }
          public tbl_Course Course { get; set; }
          public tbl_User User { get; set; }
      }
  }
  </code></pre>
  
  <p>And this sub Model has some Required Field field like <strong>tbl_User</strong> class has following required fields:</p>
  
  <pre><code>public partial class tbl_User
  {
      [Required(ErrorMessage = "Please enter {0}")]
      public string UserName { get; set; }
  
      [Required(ErrorMessage = "Please enter {0}")]
      public string Password{ get; set; }
      //And many more with Required Field
  }
  </code></pre>
  
  <p>Now my problem is, in my View i am not passing data for all this required fields but only for few. So once i click to submit button, i am calling my Controller Action Method and i am checking for ModelState errors</p>
  
  <pre><code>public ActionResult AdminInsertion(ViewModel objViewModel)
  {
      if (ModelState.IsValid)
      {
          //IF No Errors do something
      }
      return View();
  }
  </code></pre>
  
  <p>So everytime my Modelstate.Isvalid is returning false due to Validation Error which i gave in those 4 classes i.e., tbl_Roles, tbl_Category, tbl_Course and tbl_User. So what i want is to Clear all those error for which i am not passing Data, something like</p>
  
  <pre><code>//Here i want to go to individual classes ex: item should contains all tbl_Roles column fields
  foreach(var item in ModelState.Keys)
  {
      //Now i want to Get Key items of each individual class which is causing Error 
      foreach(string Key in item)
      {
           //Here i am going to clear all those error for which i am not passing data
           ModelState[Key].Error.Clear();
      }
  }
  </code></pre>
  
  <p>But my problem is, i am not able to access fields of tbl_Roles, tbl_Category, tbl_Course and tbl_User. ,How can clear only selected field errors here?</p>