我正在使用此查询:
select EmployeeId, receptionist_name, date_of_sale,
count(date_of_sale)
from FrontOffice
group By EmployeeId, receptionist_name, date_of_sale
order by date_of_sale
用于填充网格视图。但是我可以绑定EmployeeId
,receptionist_name
,date_of_sale
,所以你能告诉我如何在网格视图中绑定第4列以及如何填充网格视图。
更新:以下是我正在使用的代码:
<Columns>
<asp:BoundField HeaderText="Date" DataField="date_of_sale" />
<asp:BoundField HeaderText="Employe Id" DataField="EmployeeId" />
<asp:BoundField HeaderText="Receiptist Name" DataField="receptionist_name" />
<asp:TemplateField HeaderText="No. of Prospectus Sale">
<ItemTemplate>
<asp:Label ID="salecount" runat="server"
Text='<%# Eval("SaleCount") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
答案 0 :(得分:2)
执行以下操作:
将您的查询更改为:
select EmployeeId, receptionist_name, date_of_sale,
count(date_of_sale) as Total from FrontOffice group By EmployeeId,
receptionist_name, date_of_sale order by date_of_sale
将Gridview代码更改为:
Replace Eval("SaleCount") to Eval("Total")
答案 1 :(得分:1)
而不是更改整个代码只需将列别名为count(date_of_sale) As SaleCount
<Colums>
<asp:BoundField HeaderText="Date" DataField="date_of_sale" />
<asp:BoundField HeaderText="Employe Id" DataField="EmployeeId" />
<asp:BoundField HeaderText="Receiptist Name" DataField="receptionist_name" />
<asp:BoundField HeaderText="No. of Prospectus Sale" DataField="SaleCount" />
</Columns>