SELECT
CAST(date AS DATE),
SUM(amt) AS totamt
FROM TableName
GROUP BY CAST(date AS DATE)
当我使用简单查询时,这工作正常,但是当通过gridview绑定数据时,这不起作用并抛出错误:
DataBinding:'System.Data.Common.DataRecordInternal'不包含名为'ExpenseDate'的属性。
答案 0 :(得分:2)
您没有从数据库中选择ExpenseDate
并尝试将该列绑定到gridview中。您应该编辑数据库查询以选择ExpenseDate
,然后将其绑定在前端或从前端删除该绑定。
答案 1 :(得分:0)
我认为您应该按照gridview
的预期重命名日期列SELECT
CAST(date AS DATE) as ExpenseDate,
SUM(amt) AS totamt
FROM TableName
GROUP BY CAST(date AS DATE)