このコードを使用すると、「入力配列がこのテーブルの列数よりも長くなっています」というエラーが表示されます
DataTable dtMain = new DataTable();
var qry = from c in db.Categories where c.SubCategoryName.Contains(txtSearch.Text.Trim()) select c;
foreach (var k in qry)
{
var qry1 = from c in db.ProductMasters where c.ProductNameID == k.CategoryID
select new { ProductID = c.ProductID,
TagID = c.TagID,
ProductNameID = (from d in db.Categories
where d.CategoryID == c.ProductNameID
select d.SubCategoryName).FirstOrDefault(),
CategoryID = (from d in db.Categories
where d.CategoryID == c.CategoryID
select d.CategoryName).FirstOrDefault(),
ProductType = c.ProductType,
Maker = c.Maker,
Model = c.Model,
SerialNo = c.SerialNo,
MACAddress = c.MACAddress,
Warranty = c.Warranty,
Price = c.Price,
ProductOrderNo = c.ProductOrderNo,
VendorID = (from d in db.Vendors
where d.VendorID == c.VendorID
select d.VendorName).FirstOrDefault(),
PurchaseDate = c.PurchaseDate.ToString().Substring(0, 10),
ProductStatus = c.ProductStatus,
Remark = c.Remark };
dtMain.Rows.Add(qry1);
}
gridProduct.DataSource = dtMain;
gridProduct.DataBind();