Am trying to sum the total in the footer if a gridview,
but am getting the error "Specified argument was out of the range of valid values.
Parameter name: index "..Its Printing one cell value in the footer..
But for the seond sum,it showing the error, the value is getting,
Help me pls..
Here is the ode snippent
Expand|Select|Wrap|Line Numbers
- Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
- Dim sumPurchase As Double
- sumPurchase = 0
- sumPurchase = Ds.Tables(0).Compute("SUM(Purchase)", String.Empty).ToString
- 'If e.Row.RowType = DataControlRowType.DataRow Then
- ' sumPurchase += Convert.ToDouble(DataBinder.Eval(e.Row.DataItem, "Purchase"))
- 'Else
- If e.Row.RowType = DataControlRowType.Footer Then
- e.Row.Cells(0).Text = "Total"
- e.Row.Cells(2).Text = FormatCurrency(sumPurchase, 0)
- 'e.Row.Cells(2).Text = sumPurchase
- 'e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Right
- 'e.Row.Font.Bold = True
- End If
- End Sub