Click here to Skip to main content
15,943,233 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am fetching Values from database
inside a gridview
and assigning a "---" string in the cells where
value is null
I want to summarize the values in the footer of the gridview
its running fine when there is no null or "---"
in the row cells
But i am not able to sum the rows containing "---"


i have tried
If e.Row.RowType = DataControlRowType.DataRow Then

            sum = sum + Convert.ToDecimal(e.Row.Cells(1).Text))
        ElseIf e.Row.RowType = DataControlRowType.Footer Then

            e.Row.Cells(0).Text = "Total"
            e.Row.Cells(1).Text = sum.ToString()
            e.Row.Font.Bold = True
            e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Right
        End If

how can i achieve this
Posted
Updated 24-Apr-12 19:33pm
v2

Add check before addition

if((e.Row.Cells(1).Text).TOString())!="---")
sum = sum + Convert.ToDecimal(e.Row.Cells(1).Text))
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900