I’m having problem with datagrid view. I have attached an image with the code & error message. I want to know the reason of this error. Thanks.
I’m having problem with datagrid view. I have attached an image with the code
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You don’t need the LINQ query. just set the list as the DataSource. There is no need to set the DataMember in this case.
EDIT
LINQ query is returning
IEnumerable; however the DataGridView class supports the standard Windows Forms data-binding model. This means the data source can be of any type that implements one of the following interfaces: IList, IListSource, IBindingList, and IBindingListView. So you will need to callToList()to your LINQ result. Read more about this on this MSDN LinkHowever in your case doing this is same as setting
productListas DataSource (I mean the results will be the same, as there is no sorting or grouping involved in the LINQ query).If you want to play with LINQ, try this out (your list will be ordered by
ProductPricein ascending order)