我正面对这个但无法解决它。这来自List。遇到问题
AddOnTriggerItems = gvTriggerProduct.Rows.Cast<GridViewRow>().Select(rowItem => new AddOnTriggerItem()
ProjectA.TEST.BE.AddOn addOn = new ProjectA.TEST.BE.AddOn()
{
AddCode = addCode,
CreatedTime = DateTime.Now,
ModifiedTime = DateTime.Now,
AddOnTriggers = gvTriggerProduct.Rows.Cast<GridViewRow>().Select(row => new AddOnTrigger()
{
AddOnTriggerItems = gvTriggerProduct.Rows.Cast<GridViewRow>().Select(rowItem => new AddOnTriggerItem()
{
ProductTypeID = gvTriggerProduct.Rows[rowItem.RowIndex].Cells[1].Text.ToString(),
ProductCode = gvTriggerProduct.Rows[rowItem.RowIndex].Cells[2].Text.ToString(),
CreatedTime = DateTime.Now,
ModifiedTime = DateTime.Now
}).ToList(),
ActiveStatus = 1,
CreatedTime = DateTime.Now,
ModifiedTime = DateTime.Now
}).ToList(),
AddOnProducts = gvAddOnProduct.Rows.Cast<GridViewRow>().Select(rowAddOnProducts => new AddOnProduct()
{
ProductTypeID = gvAddOnProduct.Rows[rowItem.RowIndex].Cells[2].Text.ToString(),
ProductCode = gvAddOnProduct.Rows[rowItem.RowIndex].Cells[2].Text.ToString(),
CreatedTime = DateTime.Now,
ModifiedTime = DateTime.Now,
AddOnProductAllotments = addOnProductAllotmentSession.Where(p => (p.ProductID == (Convert.ToString(((HiddenField)rowAddOnProducts.FindControl("ProductID")).Value)))).ToList(),
}).ToList()
};
答案 0 :(得分:-1)
谢谢grek和derloopkat。 Grek的提示:问题可以在语句中从错误行开始的任何地方
我改变了3个部分。
我不能拥有2个gvTriggerProduct。
我现有代码中的一部分(不在此处)。缺少“.Value”。 Grek的提示Convert.ToByte(((DropDownList)rowItem.FindControl(“ddlMinTriggerQuantity”))。SelectedItem
Error: Cannot implicitly convert type 'void' to 'System.Collections.Generic.List'
List<AddOnTrigger> triggerlist = new List<AddOnTrigger>();
triggerList.Add(new AddOnTrigger
{
AddOnTriggerItems = gvTriggerProduct.Rows.Cast<GridViewRow>().Select(rowItem => new AddOnTriggerItem()
{
ProductTypeID = gvTriggerProduct.Rows[rowItem.RowIndex].Cells[1].Text.ToString(),
ProductCode = gvTriggerProduct.Rows[rowItem.RowIndex].Cells[2].Text.ToString(),
CreatedTime = DateTime.Now,
ModifiedTime = DateTime.Now
}).ToList(),
ActiveStatus = 1,
CreatedTime = DateTime.Now,
ModifiedTime = DateTime.Now}
});
ProjectA.TEST.BE.AddOn addOn = new ProjectA.TEST.BE.AddOn()
{
AddCode = addCode,
CreatedTime = DateTime.Now,
ModifiedTime = DateTime.Now,
AddOnTriggers = triggerlist
AddOnProducts = gvAddOnProduct.Rows.Cast<GridViewRow>().Select(rowAddOnProducts => new AddOnProduct()
{
ProductTypeID = gvAddOnProduct.Rows[rowItem.RowIndex].Cells[2].Text.ToString(),
ProductCode = gvAddOnProduct.Rows[rowItem.RowIndex].Cells[2].Text.ToString(),
CreatedTime = DateTime.Now,
ModifiedTime = DateTime.Now,
AddOnProductAllotments = addOnProductAllotmentSession.Where(p => (p.ProductID == (Convert.ToString(((HiddenField)rowAddOnProducts.FindControl("ProductID")).Value )))).ToList(),
}).ToList()
};