Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Summary Rows for Datagrid

Status
Not open for further replies.

tpr25

MIS
Jul 8, 2004
6
US
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:

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 myTotal is

Code:
Private myTotal As System.Int16

Any help would be appreciated. If i need to post anymore information, please let me know and I will post it.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top