title: How to update database from selecting an item in listbox - windows phoene 7?
body: <p>I am developing a windows phone 7 application which requires an update operation..I have the following table class.</p>
  
  <pre><code>[Table]
  public class StudentTable
  {
  
      [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
      public int StudentID
      {
          get;
          set;
      }
  
      [Column (CanBeNull = false)]
      public string StudentName
      {
          get;
          set;
      }
      [Column(CanBeNull = false)]
      public string StudentClass
      {
          get;
          set;
      }
      [Column(CanBeNull = false)]
      public DateTime regDate
      {
          get;
          set;
      }
  }
  </code></pre>
  
  <p>Im getting values for each student with the following method..</p>
  
  <pre><code> using (StudentDataContext context = new StudentDataContext(strConnectionString))
          {
  
              StudentTable newStudent = new StudentTable
              {
  
                  StudentName = textBox1.Text.ToString(),
                  StudentClass = textBox2.Text.ToString(), 
                  regDate = ((DateTime) datePicker.Value).Date.Add(((DateTime)timePicker.Value).TimeOfDay) 
  
              };
  
              context.StudentInfo.InsertOnSubmit(newStudent);
              context.SubmitChanges();
  
          }
  </code></pre>
  
  <p>and displaying the students in listbox....</p>
  
  <pre><code>                 &lt;ListBox HorizontalAlignment="Left"  Name="StudentlistBox1" ItemsSource="{Binding}"  Loaded="StudentlistBox1_Loaded"&gt;
                   &lt;ListBox.ItemTemplate&gt;
                       &lt;DataTemplate&gt;
                           &lt;StackPanel&gt;
                                 &lt;TextBlock Text="{Binding StudentName}" FontSize="{StaticResource PhoneFontSizeLarge}"&gt;&lt;/TextBlock&gt;
                                 &lt;TextBlock Text="{Binding StudentClass}" FontSize="{StaticResource PhoneFontSizeLarge}"&gt;&lt;/TextBlock&gt;
                                 &lt;TextBlock Text="{Binding regDate}" FontSize="{StaticResource PhoneFontSizeSmall}"&gt;&lt;/TextBlock&gt;
                              &lt;/StackPanel&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/ListBox.ItemTemplate&gt;
                  &lt;/ListBox&gt;
  </code></pre>
  
  <p>Im trying to code so that each selected item in the listbox would lead to a page where i can update the selected record.
  If i get the primary key of the selected item, i believe i can do it...How do I select the student in the listbox and pass that students id? any ideas.....im new to windows phone 7..please help..</p>