title: How to get listbox selected item value
body: <p>I am working with C# .NET 4.0</p>
  
  <p>I am trying to get the value of a single selected item in a listbox.</p>
  
  <p>This is how I populate the control:</p>
  
  <pre><code>this.files_lb.DataSource = DataTable object
  </code></pre>
  
  <p>In my designer, I have specified file_name as the DisplayMember and file_id as the DisplayValue</p>
  
  <p>After selecting an item in the listbox, I tried the following to get the value:</p>
  
  <pre><code>this.files_lb.SelectedValue.ToString()
  </code></pre>
  
  <p>But all it returns is <code>"System.Data.DataRowView".</code></p>
  
  <p>At this link : <a href="https://stackoverflow.com/questions/15003095/getting-value-of-selected-item-in-list-box-as-string">Getting value of selected item in list box as string</a></p>
  
  <p>someone suggested -</p>
  
  <pre><code>String SelectedItem = listBox1.SelectedItem.Value
  </code></pre>
  
  <p>However, 'Value' is not an option when I try this.</p>
  
  <p>How can I get the ValueMember value from a single selected item in a listbox?</p>