Author: MEight | Posted on: 9/10/2009 4:20:28 PM | Views : 327

I created a DataContext class that holds the LINQ queries that find the data for my dropdown list.
 
public List<string> GetAllProductTypes()
{
var res = from p in ProductTypes
select new {p.productTypeID, p.productTypeName};
return res.ToList();
}
 
I want to databind this data to my dropdownlist (ddProduct).
 
MyDataContext db = new MyDataContext();
ddProduct.DataSource = db.GetAllProductTypes();
dd.DataTextField = "productTypeName";
dd.DataValueField = "productTypeID";
dd.DataBind();
 
The error I'm getting is in the DataContext. It states that I cannot implicitly convert type System.Collections.Generic.List<AnonymousType#1> to System.Collections.Generic.List<string>
How do I fix this problem?
With LINQ, can I somehow store the "res" as a DatatTable? (I then j ...

Go to the complete details ...