Basically when I try to move my queries result into a usable format, I get given outputs such as “systems.collections.whatever”
Instead I want the actual number returned.
this is how I select the value I want
listBox2.DisplayMemberPath = "MonthlyHourLimit";
listBox2.ItemsSource = e.Result;
if (this.listBox2.Items.Count > 0)
this.listBox2.SelectedIndex = 0;
limit = listBox2.SelectedItem.ToString();
I should get “156” but instead I get “Timesheet_System.userDataService.UserData””
ListBox.SelectedItem is of type
object, and theToString()of any object is the type name.To get the actual string value, you need to cast
listBox2.SelectedItemto your data type first.I’m assuming your
SelectedItemis of typeUserDatabased on the name it’s giving you with.ToString(), so use something like this:Or if you want
limitto equal theDisplayMemberPath