Thursday, April 3, 2008

LINQ to SQL and the DataGridView control

A DataGridView control won't bind directly to an IEnumerable object, so two options are:

1. Create a BindingSource, set its DataSource to the IEnumerable object, then set the DataGridView.DataSource property to the BindingSource.

2. Bind the DataGridView.DataSource property to the IEnumerable object's ToList() method.

Thanks to Ken Tucker on Microsoft Forums for this tip.

2 comments:

Transplante de Cabelo said...

Hello. This post is likeable, and your blog is very interesting, congratulations :-). I will add in my blogroll =). If possible gives a last there on my blog, it is about the Transplante de Cabelo, I hope you enjoy. The address is http://transplante-de-cabelo.blogspot.com. A hug.

ps3 said...

Dude, saved me! ;] very nice indeed