title: Update datagridview from row click on another datagridview
body: <p>I have two datagridviews on a winform.  The first one contains an ID column.  I want to select a row in that datagridview and have the second dgv update based on that ID.  The second dgv is bound to XML and default loads all nodes named "Product".  The XML looks like this:</p>
  
  <pre><code>&lt;Class1&gt;
    &lt;Product .... /&gt;
    &lt;Product .... /&gt;
  &lt;/Class1&gt;
  &lt;Class2&gt;
    &lt;Product .... /&gt;
    &lt;Product .... /&gt;
  &lt;/Class2&gt;
  </code></pre>
  
  <p>The second dgv loads all nodes named Product correctly, all within all the Classx nodes.  I set up the event on the first datagridview and can capture the ID and narrow down the result set.  If I click on row ID "1" in the first dgv I need the second dgv to load just the Products in "Class1."  This is not working:</p>
  
  <pre><code>private void dgClasses_CellClick(object sender, DataGridViewCellEventArgs e)
      {
          DataGridView dgv = sender as DataGridView;
          if (dgv == null)
              return;
          if (dgv.CurrentRow.Selected)
          {
              string selectedval;
              DataGridViewRow row = this.dgClasses.SelectedRows[0];
              selectedval = row.Cells["ID"].Value.ToString();
  
              XmlReader xmlFile = XmlReader.Create(txtFileLocation.Text, new XmlReaderSettings());
              DataSet dataSet = new DataSet();
  
              dataSet.ReadXml(xmlFile);
              dgProducts.DataSource = null;
              dgProducts.Refresh();
              dgProducts.DataSource = dataSet.Tables["Class" + selectedval + "/Product"];
              xmlFile.Close();
          }
      }
  </code></pre>
  
  <p>How do I refresh the second dgv to show only the Products in the Class ID # selected in the first dgv?</p>
  
  <p>More info:
  New to LINQ to XML but tried something like this and still no data.  "Class is an attribute on the Product node and if it matches the selectedval (ID) then I need those records.</p>
  
  <pre><code>XDocument xml = XDocument.Load(txtFileLocation.Text);
  
              var nodes = (from n in xml.Descendants("Class" + selectedval)
                           where n.Element("Product").Attribute("Class").Value == selectedval
                           select n.Element("Product").Descendants().Elements()).ToList();
  
              dgProducts.DataSource = null;
              dgProducts.Refresh();
              dgProducts.DataSource = nodes;
  </code></pre>