hi
i want to load a table of database to a listview.i know how to create columns for listview and how to add items in them,
but i don't know how to add data from database with linq.
i write this code:
databaseDataContext db = new databaseDataContext();
var query = db.accountinfos;
for (int i = 0; i < query.Count();i++ )
{
var field = db.accountinfos.Where(c => c.id == i+1).Single();
ListViewItem item = new ListViewItem(field.bankname.ToString());
item.SubItems.Add(field.accountnumber.ToString());
}
please help me.
thanks

Jignesh TrivediPosted Mar 24, 2014, 3:00 AM
hi,
I think you code is correct just you have to add List Item in to list box
ListView1.Add(item);
hope this will help you.