DataSource, Take 2

  • Thread starter Thread starter MS
  • Start date Start date
M

MS

OK, I figured out the DisplayMember since I last connected, but now when I
try to access lstFolderTypes.Item(0).ToString, I get
"System.Data.DataRowView" , yet the folder names are properly displayed in
the listbox as represented in the database. Any ideas??

If more than one copy of this mesage hits, I apologize. I created 2 and
never saw them posted.
 
When listbox is bound to a DataTable or DataView Items(i) return
DataRowView.
DataRowView has a member called Row, which is of type DataRow and gives you
the access to *any* field in the selected row:
DataRow row = (listBox.Item(0) as DataRowView).Row;

If you set ValueMember property to a valid field name, the SelectedValue
property will return the value of this filed in the selected row, while Text
property will return the Displaymember field value
 
Back
Top