title: Can't Get the selected value of spinner from my custom listview adapter in xamarin. C#
body: <p>Xamarin Help .</p>
  
  <p>Can't Get selected value for spinner in  my custom listview adapter.</p>
  
  <p>MyListViewAdapter.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Data.SqlClient;
  
  using Android.App;
  using Android.Content;
  using Android.OS;
  using Android.Runtime;
  using Android.Util;
  using Android.Views;
  using Android.Widget;
  
  namespace Kites
  {
  public class AttendenceViewAdapter : BaseAdapter&lt;string&gt;
  {
      private List&lt;string&gt; mstudents;
  
      private Context mcontext;
  
  
  
      public AttendenceViewAdapter(Context context, List&lt;string&gt; stud)
      {
          mstudents = stud;
          mcontext = context;
  
  
      }
      public override int Count 
      {
          get 
          {
              return mstudents.Count;
  
  
          }
      }
      public override long GetItemId (int position)
      {
          return position;
      }
      public override string this[int position] 
      {
          get 
          {
              return mstudents [position].ToString();
  
  
          }
      }
  
  
  
      public override View GetView (int position, View convertView,   ViewGroup parent)
      {
          View view = convertView;
          if (view == null) // otherwise create a new one
              view = LayoutInflater.From(mcontext).Inflate(Resource.Layout.listview_attendence , null, false);
          // set view properties to reflect data for the given row
          TextView txtStudent = view.FindViewById&lt;TextView&gt;(Resource.Id.textStudentNameTeacherAttendence);
          txtStudent.Text = mstudents[position];
          Spinner spinner = view.FindViewById&lt;Spinner&gt; (Resource.Id.spinnerTeacherAttendence);
  
  
  
          var adapter = ArrayAdapter.CreateFromResource (mcontext, Resource.Array.attendence_array, Android.Resource.Layout.SimpleDropDownItem1Line);
  
          adapter.SetDropDownViewResource (Android.Resource.Layout.SimpleSpinnerDropDownItem);
  
          spinner.Focusable = false;
          spinner.FocusableInTouchMode = false;
          spinner.Clickable = true;
  
          spinner.ItemSelected += Spinner_ItemSelected;
  
          spinner.Adapter = adapter;
          var abcde = spinner.SelectedItemPosition;
          spinner.SetSelection (abcde);
  
  
  
  
          // return the view, populated with data, for display
          return view;
      }
  
      void Spinner_ItemSelected (object sender, AdapterView.ItemSelectedEventArgs e)
      {
          Spinner spinner = (Spinner)sender;
          var abc = spinner.SelectedItemPosition;
  
          spinner.RequestFocusFromTouch ();
          spinner.SetSelection (abc);
      }
  
  
  
  }
  }
  </code></pre>
  
  <p>Main Activity.cs</p>
  
  <pre><code>ListView lsStu = FindViewById&lt;ListView&gt; (Resource.Id.listStudentAttendence);
          AttendenceViewAdapter adapter = new AttendenceViewAdapter (this, mstudents);
  lsStu.Adapter = adapter;
  
  
  for(int i = 0; i &lt; abc; i++)
              {
  
              View view = adapter.GetView(i, null, null);
              TextView txtStudentName = view.FindViewById&lt;TextView&gt; (Resource.Id.textStudentNameTeacherAttendence);
              string txtSN = txtStudentName.Text;
              Spinner spinner = view.FindViewById&lt;Spinner&gt; (Resource.Id.spinnerTeacherAttendence);
  
              var txtS = spinner.SelectedItem;
  // I Cant Get The Selected Value Here. , I Am Getting the default Value not the selected value .do i do that
  
              string studentattendence = "insert into student_attendence values ('" + txtClassID.Text + "','" + txtClassName.Text + "','" + txtDate.Text + "','" + txtSN + "','" + txtS + "');";
  
                  SqlCommand abcdedh = new SqlCommand (studentattendence, con);
                  abcdedh.ExecuteNonQuery ();
  
                  Toast.MakeText (this, "Attendence Saved", ToastLength.Short).Show();
  
  
              }
  </code></pre>
  
  <p>I get the default value at position 0 but not the value which i have selected.
  when i place a breakpoint in mylistviewadapter i get the selected value position every time i select a new value but i am not getting it in the main activity please help me.</p>