Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows forms listbox.selecteditem displaying "System.Data.DataRowView" instead of actual value
    primarykey
    data
    text
    <p>I am creating a Windows form application in Visual Studio 2010. I have an Access database which has a table 'ResearcherInfo'.</p> <p>In my windows form, I have a listbox which gets populated with the contents of the column name 'Researcher Name' of this table. </p> <p>However when I try to get the selected items of this text box, it only returns me a null value or sometimes System.Data.DataRowView depending on how I access it</p> <p>I have tried</p> <pre><code> string name = projectmembers_lst.SelectedItem.ToString(); </code></pre> <p>While debugging when I hover the mouse over the 'projectmembers_lst' word, it correctly shows me projectmembers_lst = {SelectedItem = "Jerome"}</p> <p>but on hovering over the string 'name', it shows "name = "System.Data.DataRowView""</p> <p>i even tried copying to an array </p> <pre><code> foreach (Object selecteditem in projectmembers_lst.SelectedItems) { object[] objCollection = new object[projectmembers_lst.SelectedItems.Count]; projectmembers_lst.SelectedItems.CopyTo(objCollection, 0); MessageBox.Show(objCollection[0] as string); } </code></pre> <p>Nothing gets me the selected items. I am not sure what is wrong here. </p> <p><strong>Populating the List Box:</strong> </p> <p>1) I have the added the access table 'ResearcherInfo'. as a data source for the web form application. </p> <p>2) In the properties of the Listbox, under the Datasource tab, I have linked this table and given the display member and value member property of the Listbox as the column name 'Researcher Name' of the table.</p> <p>So basically my Listbox displays the Researcher Names from the Researcher info table. attached is a snap shot. <img src="https://i.stack.imgur.com/ISIwk.jpg" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload