点击搜索按钮时遇到Cannot find column CustomerItemNoAppend.
错误。
条件:如果用户不是内部用户,请隐藏2列。我当前的查询不涉及列CustomerItemNoAppend
和ManufacturerItemNoAppend
。
由@ tetsuya-yamamoto建议,使用Cannot find column
时不会遇到getColumnSafe
的错误。
public IQueryable GetAllInventorySummary()
{
var query = from summary in dataContext.Q_TBL_INVENTORY_SUMMARIES
group summary by new
{
poaItemNo = summary.POAItemNo,
customerItemNo = summary.CustomerItemNo,
manufacturerItemNo = summary.ManufacturerItemNo,
itemDescription = summary.ItemDescription,
uom = summary.UOM,
} into grp
select new
{
POAItemNo = grp.Key.poaItemNo,
CustomerItemNo = grp.Key.customerItemNo,
ManufacturerItemNo = grp.Key.manufacturerItemNo,
ItemDescription = grp.Key.itemDescription,
OnHandQty = grp.Sum(s => s.OnHandQty),
UOM = grp.Key.uom,
InventoryLocationNo = "All",
};
return query;
}
主要方法:
if (profile.UserInternal != 'Y')
{
RadGrid1.DataSource = inventory.GetAllInventorySummary(profile.CompanyID);
RadGrid1.MasterTableView.GetColumnSafe("CustomerItemNoAppend").Visible = false;
RadGrid1.MasterTableView.GetColumnSafe("ManufacturerItemNoAppend").Visible = false;
}
else
{
RadGrid1.DataSource = inventory.GetAllInventorySummary();
RadGrid1.MasterTableView.GetColumnSafe("CustomerItemNo").Visible = false;
RadGrid1.MasterTableView.GetColumnSafe("ManufacturerItemNo").Visible = false;
}
}
else
{
if (profile.UserInternal != 'Y')
{
RadGrid1.DataSource = inventory.GetInventorySummaryByLocation(InventoryLocation.SelectedValue);
RadGrid1.MasterTableView.GetColumnSafe("CustomerItemNoAppend").Visible = false;
RadGrid1.MasterTableView.GetColumnSafe("ManufacturerItemNoAppend").Visible = false;
}
else
{
RadGrid1.DataSource = inventory.GetInventorySummaryByLocation(InventoryLocation.SelectedValue);
RadGrid1.MasterTableView.GetColumnSafe("CustomerItemNo").Visible = false;
RadGrid1.MasterTableView.GetColumnSafe("ManufacturerItemNo").Visible = false;
}
}
搜索按钮:
protected void btnSearch_Click(object sender, EventArgs e)
{
InventoryProvider inventory = new InventoryProvider();
GetInventorySummary();
DataProvider.CloseConnectionDB();
RadGrid1.DataBind();
}
Telerik Radgrid列:
<telerik:GridBoundColumn HeaderText="Customer Item No." UniqueName="CustomerItemNo"
HeaderStyle-Width="150px" SortExpression="CustomerItemNo" DataField="CustomerItemNo"
DataType="System.String" />
<telerik:GridBoundColumn HeaderText="Manufacturer Item No." UniqueName="ManufacturerItemNo"
SortExpression="ManufacturerItemNo" DataField="ManufacturerItemNo" DataType="System.String" />
<telerik:GridBoundColumn HeaderText="Customer Item No. Appended" UniqueName="CustomerItemNoAppend"
HeaderStyle-Width="150px" SortExpression="CustomerItemNoAppend" DataField="CustomerItemNoAppend"
DataType="System.String" />
<telerik:GridBoundColumn HeaderText="Manufacturer Item No. Appended" UniqueName="ManufacturerItemNoAppend"
HeaderStyle-Width="150px" SortExpression="ManufacturerItemNoAppend" DataField="ManufacturerItemNoAppend"
DataType="System.String" />