Simplest way to use a DatagridView with Linq to SQL
Posted
by
Martín Marconcini
on Stack Overflow
See other posts from Stack Overflow
or by Martín Marconcini
Published on 2009-06-16T11:06:46Z
Indexed on
2011/02/03
23:25 UTC
Read the original article
Hit count: 266
Hi, I have never used datagrids and such, but today I came across a simple problem and decided to "databind" stuff to finish this faster, however I've found that it doesn't work as I was expecting.
I though that by doing something as simple as:
var q = from cust in dc.Customers
where cust.FirstName == someString
select cust;
var list = new BindingList<Customer>(q.ToList());
return list;
Then using that list in a DataGridView1.DataSource was all that I needed, however, no matter how much I google, I can't find a decent example on how to populate (for add/edit/modify) the results of a single table query into a DataGridView1. Most samples talk about ASP.NET which I lack, this is WinForms.
Any ideas?
I've came across other posts and the GetNewBindingList, but that doesn't seem to change much.
What am I missing (must be obvious)?
Thanks in advance.
Martin.
© Stack Overflow or respective owner