我很抱歉发布了另一个转换类型错误,但在查看并尝试了近两天的每个示例之后,我无法让它工作。
我需要做些什么才能让它发挥作用????
public IEnumerable<Product> BindProductDropDown([Control("ddBrand")] int BrandID)
{
if (BrandID > 0)
{
try
{
var prod = (from p in _DbContext.Products
join pc in _DbContext.ProductCategories on p.ProductCategoryID equals pc.ProductCategoryId
where pc.BrandID == BrandID
orderby p.OrderBy, p.Name
select new
{
p.ProductID,
p.ItemNumber
});
var c = prod.Count();
return prod;
}
catch (Exception exp)
{
ErrorLabel.Text = exp.Message;
return null;
}
}
else
{
ErrorLabel.Text = "Please select a brand from the drop drown list of brands above.";
return null;
}
}
#
public IEnumerable<Product> BindProductDropDown([Control("ddBrand")] int BrandID)
{
if (BrandID > 0)
{
try
{
var prod = (from p in _DbContext.Products
join pc in _DbContext.ProductCategories on p.ProductCategoryID equals pc.ProductCategoryId
where pc.BrandID == BrandID
orderby p.OrderBy, p.Name
select new Product
{
p.ProductID,
p.ItemNumber
});
var c = prod.Count();
return prod;
}
catch (Exception exp)
{
ErrorLabel.Text = exp.Message;
return null;
}
}
else
{
ErrorLabel.Text = "Please select a brand from the drop drown list of brands above.";
return null;
}
}