title: C# Windows Forms ListView get selected row values
body: <p>I have a <code>ListView</code> populated by a SQL db and want to be able to edit the values once I select a row and click the edit button.</p>
  
  <p>When I click the "edit" button the values from the selected row should be set in the textboxes, but I get this error "<strong>Object reference not set to an instance of an object.</strong>"
  Why isn't this working?</p>
  
  <pre><code>private void btnEdit_Click(object sender, EventArgs e)
      {
          this.txtid.Text = lvBrands.SelectedItems["id"].Text.ToString();  
          this.txtName.Text = lvBrands.SelectedItems["name"].Text.ToString();
  
      }
  </code></pre>