error BindingSource.current using linq [modified]
-
hi all i having a problem using linq with may binding source. i coded it in this way. dim MyBindingSource as new BindingSource() dim CustomerList = FROM customer In MyDataContext.tblCustomer _ SELEC customer.CustomerID, customer.CustomerName MyBindingSource.DataSource = CustomerList msgbox (MyBindingSource.Current("CustomerID") error occur on msgbox (MyBindingSource.Current("CustomerID") line? it says "No default member found of type '<>f__AnonymousType0`11[System.String, .etc What should i do.. Please help thanks..
modified on Monday, April 26, 2010 1:05 AM
-
hi all i having a problem using linq with may binding source. i coded it in this way. dim MyBindingSource as new BindingSource() dim CustomerList = FROM customer In MyDataContext.tblCustomer _ SELEC customer.CustomerID, customer.CustomerName MyBindingSource.DataSource = CustomerList msgbox (MyBindingSource.Current("CustomerID") error occur on msgbox (MyBindingSource.Current("CustomerID") line? it says "No default member found of type '<>f__AnonymousType0`11[System.String, .etc What should i do.. Please help thanks..
modified on Monday, April 26, 2010 1:05 AM
I've seen a solution for this problem from other person with same problem as it is: Add "System.Web" to may references then imports System.Web.UI then by using DataBinder such this: msgbox (DataBinder.eval(MyBindingSource.Current(), "CustomerID")) but another problem pop up.. when i use the addnew method of my bindingsource an error halted me.. saying that my list is readonly and has no way to execute my addnew... MyBindingSource.Addnew() Please help! thanks in advance...
-
hi all i having a problem using linq with may binding source. i coded it in this way. dim MyBindingSource as new BindingSource() dim CustomerList = FROM customer In MyDataContext.tblCustomer _ SELEC customer.CustomerID, customer.CustomerName MyBindingSource.DataSource = CustomerList msgbox (MyBindingSource.Current("CustomerID") error occur on msgbox (MyBindingSource.Current("CustomerID") line? it says "No default member found of type '<>f__AnonymousType0`11[System.String, .etc What should i do.. Please help thanks..
modified on Monday, April 26, 2010 1:05 AM
Hi, The context of which you are using to try and get the customerId is incorrect, the reason is because the current item that you are trying to get data from is an anonymous type. This type doesn't have any default members like the exception states. Unfortunately, I don't have any exact support for this sample code you put, but if you were using a real type (even if you made the type yourself using a custom class) you could typecast the item contained in MyBindingSource.Current to retrieve the data from it correctly. hope this helps