TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Avuya Mxoli
NA
236
209k
WPF Listbox and DataTables
Jun 11 2012 8:46 AM
Hi all,
I am trying to bind data that's in my dataTable to a listbox with no luck. My datatable is in the business layer(I'm using 3-tier architecture) so I declare my BusinessLayer globally then when the user chooses something from a combobox I want items to be displayed in my listbox. The data in a listbox is not coming from a specific table in my database though, that is why I cannot set DisplayMember and ValueMember for my listbox. The data is just something like say SQL statement that :"select name,surname, From Patient Where Surburb = 'NewLands';" so this is not written to any table it gets retrieved when the stored procedure fires. I hope this clarifies things. So in my Business Layer I have a DataTable that uses the mentioned stored procedure and then on the code now I try to bind like this :
private void cboUnit_SelectedIndexChanged(object sender, RoutedEventArgs e)
{
lstUnassigned.ItemsSource = mdl.getUnassignedPatients().DefaultView;
}
where mdl is my business layer and getUnassignedPatients is a method that has the DataTable.
I get the following displayed as a result:
System.Data.DataRowView
it displays this four times because the "table" I'm reading from has four values. So at least I know it reads the data but the problem is in displaying it. On my xaml I didn't set any binding etc to my listbox...
I'm pretty new to WPF so this kind of problem throws me off since it's not even giving me a proper error.
Your help will be appreciated.
Reply
Answers (
5
)
Clear WPF ListBox which is bind to a list
Adding item to expander in WPF