I have a database that stores answers from a poll. There are 5 answers that can be written to the database. I know how to display a tally of each answer but I need to be able to write the percentage of each answer. Can anybody help me with this? Any help would be greatly appreciated. Thanks.
Below is the code that I am using to display the results.
Code:<asp:SqlDataSource ID="SqlDataSource6" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [Results], COUNT(*) TotalCount FROM [tblPollResults] GROUP BY Results HAVING COUNT(*) >= 1 ORDER BY COUNT(*) DESC"> </asp:SqlDataSource> <div style="padding-left: 15px"> <asp:Label ID="Label1" runat="server" Text="Survey Results" Font-Bold="True" CssClass="textlink"></asp:Label></div> <div align='center'> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource6" AutoGenerateColumns="False" ShowHeader="False" BorderStyle="None" GridLines="None" Style="margin-left: 0px" Width="150px"> <Columns> <asp:BoundField DataField="Results" HeaderText="Results" SortExpression="Results"> <ItemStyle HorizontalAlign="Left" /> </asp:BoundField> <asp:BoundField DataField="TotalCount" HeaderText="TotalCount" ReadOnly="True" SortExpression="TotalCount"> <ItemStyle HorizontalAlign="Right" /> </asp:BoundField> </Columns> </asp:GridView> </div>




Bookmarks