【发布时间】:2021-09-21 21:25:42
【问题描述】:
我需要在已经格式化为显示索引和点击的 Gridview 中以百分比显示平均点击次数。我需要将每个“点击次数”列中的数字除以同一“点击次数”列的总和。
Index Clicks %
| 1 | | 24 | | 44% |
| 2 | | 31 | | 56% |
这是我的 GridView
<asp:Table ID="Table2" runat="server">
<asp:TableRow>
<asp:TableCell>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="Index" HeaderText="Index" SortExpression="Index"></asp:BoundField>
<asp:BoundField DataField="Clicks" HeaderText="Clicks" ReadOnly="True" SortExpression="Clicks"></asp:BoundField>
</Columns>
</asp:GridView>
<asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString='<%$ ConnectionStrings:trackingstatsConnectionString %>' SelectCommand="SELECT LinkId as 'Index', count(*) as Clicks FROM Track_Click_7 where CampaignId = 18444 Group by LinkId;"></asp:SqlDataSource>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
【问题讨论】: