title: C# GridView. How to get a value of a selected item?
body: <p>I have the following problem. I have a GridView which is populated from my database with the help of this code:</p>
  
  <pre><code>private async void CreateDatabase()
  {
      SQLiteAsyncConnection conn = new SQLiteAsyncConnection("people");
  
      var query = conn.Table&lt;Person&gt;();
      var result = await query.ToListAsync();
  
      foreach (var item in result)
      {
          GridView1.Items.Add(new GridViewItem { Background = new SolidColorBrush(Colors.Green), Content = item.Name, Width = 200, Height = 200 });
      }
  }
  </code></pre>
  
  <p>I delete items from my database like this:</p>
  
  <pre><code>private async void DeleteSelectedButton_Click(object sender, RoutedEventArgs e)
  {
      SQLiteAsyncConnection conn = new SQLiteAsyncConnection("people");
      var query = conn.Table&lt;Person&gt;().Where(x =&gt; x.Name == "123");
      var result = await query.ToListAsync();
      foreach (var item in result)
      {
          await conn.DeleteAsync(item);
      }
  }
  </code></pre>
  
  <p>My questions are: What specific value can I bind to a GridView1.Item created in the first block of code so that I can retrieve it later to delete an entity in my database when this item gets selected? (i.e. 1. When populating the GridView I want each GridView.Item to be assigned with some value bound to IDs from my database; 2. I want to be able to retrieve this value when I select the item by rightclicking on it and then pressing the delete button (so that not the database entity with "123" in its name gets deleted, but the one with ID bound to the item). Any help would be really appreciated!</p>
  
  <p>P.S. Sorry for my complex sentences. </p>