hi...
foreach string s in myDictionary.Keys
   myAdapter.Add(s);

i wrote already  foreach loop in form load to populate spinner with course
names like
 protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.SaveSpinnerValueDictionary);
            // Create your application here
            studentcourse =
FindViewById<Spinner>(Resource.Id.studentcourse);
            studentno = FindViewById<EditText>(Resource.Id.studentno);
            studentaddr = FindViewById<EditText>(Resource.Id.studentaddr);
            savedict = FindViewById<Button>(Resource.Id.savedictionary);
            retreivedict =
FindViewById<Button>(Resource.Id.retreivedictionary);
             savedict.Click+=new EventHandler(savedict_Click);
            retreivedict.Click+=new EventHandler(retreivedict_Click);
            course = new Dictionary<string, int>();
            course.Add("MCA", 101);
            course.Add("MBA", 202);
            course.Add("MSc", 303);
            course.Add("Mtech", 404);
            adapter = new ArrayAdapter<string>(this,
Android.Resource.Layout.SimpleSpinnerDropDownItem);           
            foreach(string k in course.Keys) // i already wrote here and
spinner is populating with courses
                adapter.Add(k);
            studentcourse.Adapter = adapter;
            //adapter.AddAll(course.Keys);            
          
          }

my problem is for retreiving ...i save corresponding int values of
coursenames..now i want to display spinner with course name based on
corresponding value in database when i give sno in first edittext and click
on reterive button...here is code for retreiving...
 SqliteDataReader sdr = cmd.ExecuteReader();
                while (sdr.Read())
                {                   
                    int spinintval = Convert.ToInt32(sdr["SCOURSE"]);//here
i took SCOURSE value into int //variable spinval
                    if (course.ContainsKey(spinintval)) //here course is
dictionary i defined previously
                      {
studentcourse.SetSelection(adapter.GetPosition(spinintval)); }   //here
studentcourse is spinner...but here this is not working to display spinner
with corresponding coursename              
                                    
                    studentaddr.Text = Convert.ToString(sdr["SADD"]);           
                    
                }
how to set selected coursename in spinner when we enter sno in first
edittext and click on retreive button
i saved data  in database like this
sno      scourse    saddress
1           MCA        UK
2           MBA        USA
when i enter 2 in sno edittext and click on retrieve button the spinner
should display with MBA ...



--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Enhancement-code-for-Spinner-tp5712950p5713000.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to