Hello,
I am trying to use a datagrid to give summary data. However, the column I am trying to summarize is not counting correctly. Here is the code:
I am getting the error "Input string was not in a correct format". It can't convert "" into an integer. The declaration for my total is
Any help would be appreciated. If i need to post anymore information, please let me know and I will post it.
Thanks
I am trying to use a datagrid to give summary data. However, the column I am trying to summarize is not counting correctly. Here is the code:
Code:
Private Sub SummaryGrid_ItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles SummaryGrid.ItemDataBound
Select Case e.Item.ItemType
Case ListItemType.AlternatingItem, ListItemType.Item
'Calculate total for the field of each row and alternating row.
myTotal += CInt(e.Item.Cells(1).Text)
'Format the data, and then align the text of each cell to the right.
e.Item.Cells(2).Text = Format(CInt(e.Item.Cells(2).Text), "##,##0")
e.Item.Cells(2).Attributes.Add("align", "right")
Case ListItemType.Footer
'Use the footer to display the summary row.
e.Item.Cells(0).Text = "Total Sales"
e.Item.Cells(0).Attributes.Add("align", "left")
e.Item.Cells(1).Attributes.Add("align", "left")
e.Item.Cells(1).Text = myTotal.ToString '("c")
End Select
End Sub
I am getting the error "Input string was not in a correct format". It can't convert "" into an integer. The declaration for my total is
Code:
Private myTotal As System.Int16
Thanks