Well, I've ran into a problem when binding ListBox control to DataTable.
Code:
using (DbWrapper db = DbFactory.GetConnection("SQLite").WrapIn<MyDbWrapper>())
{
db.Open();
DataTable results = db.ExecuteQuery("SELECT id,title FROM schedule");
ScheduleList.DataSource = results;
ScheduleList.DisplayMember = "title";
ScheduleList.ValueMember = "id";
}
This code is supposed to receive data from my SQLite database, and bind it to my ScheduleList, but when I compile I see my ListBox filled with System.Data.DataRowView strings.
There's no problems with database. The application is receiving data, and the data is correct. If I iterate through my datatable I will get id and title as column names, so theres nothing wrong with them.
I've read that the problem may be solved by changing binding order or setting ListBox.Sorted property to false. I've tried it all and still no success.
Any suggestions? Are there any other solutions except iterating over datarows and adding them manually?
Best Regards.