title: populating listview when item selected in spinner Xamarin
body: <p>I am creating a ListView of type multiple choices (check boxes) as below</p>
  
  <pre><code> var adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItemMultipleChoice);
                      attendanceListView.Adapter = adapter;
  </code></pre>
  
  <p>now I want to check some checkBoxes when item is selected from spinner</p>
  
  <p>and ListView is populated as</p>
  
  <pre><code>adapter.Add("Select All");
                      foreach (var item in studentInformation)
                      {
                          adapter.Add(item.studentName.ToString());
                      }
  </code></pre>
  
  <p>every thing is perfect till here. but now problem arises when selecting item from courseSpinner</p>
  
  <pre><code> private void CourseSpinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
      {
  ListView list = (ListView)sender;
                          for (int count = 0; count &lt; attendanceInformation.Count(); count++)
                      {
                          if (attendanceInformation[i].status == true)
                          {
                              selectedStudents[i] = attendanceInformation[i].studentId;
                              list.SetItemChecked(i, true);
                          }
                          else
                          {
                              list.SetItemChecked(i, false);
                          }
                      }
  
  }
  </code></pre>
  
  <p>but it throws an exception:</p>
  
  <blockquote>
    <p>System.InvalidCastException: Specified cast is not valid.</p>
  </blockquote>