Hi,
I've got what should be quite a simple question, I think!
I have a DataGridView that will display details of "Pricing". To display the DataBound DataGridView, we are using the following code.
HTML/ASP
<asp:GridView ID="grvAgentStats" runat="server" AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333"
GridLines="None" style="font-size: 12px" Width="500px" ShowFooter="True">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="Result" HeaderText="Result" ItemStyle-Wrap="false"
ItemStyle-HorizontalAlign = "Left">
<ItemStyle HorizontalAlign="Left" Wrap="False"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="Amount" HeaderText="Amount"
ItemStyle-HorizontalAlign = "Center" >
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="At" HeaderText=""
ItemStyle-HorizontalAlign = "Center">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="Fee" HeaderText="Fee"
ItemStyle-HorizontalAlign = "Center" DataFormatString="{0:c}" >
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="Equals" HeaderText=""
ItemStyle-HorizontalAlign = "Center" >
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="Total" HeaderText="Total"
ItemStyle-HorizontalAlign = "Center" DataFormatString="{0:c}"
FooterText="0.00" >
<FooterStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" HorizontalAlign="Center"/>
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" HorizontalAlign="Center"/>
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
Code-behind
Private Sub DatabindResults()
Dim SQLconn As SqlConnection
Dim SQLComm As SqlCommand
Dim SQLDa As SqlDataAdapter
Dim SQLDs As DataSet
Dim ADUsername As String = Session.Item("txtUsername")
Dim Date1 As String = ddlDates.SelectedValue
Dim ClientName As String = ddlClient.SelectedValue
SQLconn = New SqlConnection(ConfigurationManager.ConnectionStrings("Connection").ConnectionString)
SQLComm = New SqlCommand("prcHHGenAgentStats_New", SQLconn)
SQLComm.CommandType = CommandType.StoredProcedure
SQLComm.Parameters.AddWithValue("@Variable1", Month)
SQLComm.Parameters.AddWithValue("@Variable2", ADUsername)
SQLComm.Parameters.AddWithValue("@Variable3", ClientName)
SQLDa = New SqlDataAdapter(SQLComm)
SQLDs = New DataSet()
SQLDa.Fill(SQLDs, "AgentStats")
ViewState("AgentStats") = SQLDs
grvAgentStats.DataSource = SQLDs.Tables(0).DefaultView
grvAgentStats.DataBind()
End Sub
As you can see I have the footer row in there but how do I now get it to "SUM" the Total column. I was hoping to do this without using a SQL Query/Stored Procedure.
Any help will be greatly appreciated!!
Thanks,
Jammo :)