For example I have a list called Product and it has 3 columns, ProductName (which is the Title), ProductPrice and ProductType.
- ProductName is a string
- ProductPrice is a currency (double)
- ProductType is a LookUp on ProductTypes List
Normally this is easy for me if it does not contain a LookUp column, but I dont know how to deal with look up columns when Inserting.
I had tried this one but it returns an error
Specified cast is not valid.
Here is the current code
EntityList<ProductTypeItem> ProductTypes = dc.GetList<ProductTypeItem>("ProductType"); ProductItem newProduct = new ProductItem(); newProduct.Title = txtProductName.Text; newProduct.ProductPrice = double.Parse(txtProductPrice.Text); newProduct.ProductType = (from a in ProductTypes where a.Title == ddProductType.SelectedItem.Text select a).FirstOrDefault(); dc.Product.InsertOnSubmit(newProduct); dc.SubmitChanges();
What would I do with the
newProduct.ProductType as here is where the error occurs.
Please note that the ddProductType DataSource is the ProductType List and uses
Title in its