1

我正在使用这个查询:

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>
4

2 回答 2

2

执行以下操作:

  1. 将您的查询更改为:

    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

  2. 将您的 Gridview 代码更改为:

    Replace Eval("SaleCount") to Eval("Total")

于 2012-09-30T12:28:57.843 回答
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>
于 2012-09-30T12:17:08.193 回答