我正在尝试通过 linq 使用对象列表填充网格视图(我只想显示具有特定属性的某些对象)。
我得到错误...
异常详细信息:System.ArgumentNullException:值不能为空。参数名称:来源
源错误:
第 1364 行:returnInvoices = (List)Session["Invoices"]; 第 1365 行:第 1366 行:var partInvoices = from i in returnInvoices 第 1367 行:其中 i.PartNo == partNo 第 1368 行:选择新的源文件:c:\inetpub\wwwroot...\Form.aspx.cs 行:1366
protected void DoInvoicePopUp(string partNo)
{
List<Invoice> returnInvoices = (List<Invoice>)Session["Invoices"];
var partInvoices = from i in returnInvoices
where i.PartNo == partNo
select new
{
i.InvoiceID,
i.InvoiceNo,
i.InvoiceLine,
i.InvoiceDate,
i.OrderNo,
i.OrderLine,
i.OrderRel,
i.OrderLineItem,
i.OrderLineQty,
i.CustomerPO,
i.Serialized
};
GridView3.DataSource = partInvoices;
GridView3.DataBind();
pnlBlanket.Visible = pnlInvoiceSearch.Visible = true;
}
我不确定我做错了什么。List 中有 200 多个对象,那么它怎么可能是 null 呢?