problem in getting total
hi all,
i facing a problem, described belwo in detail
hope someone can can help me in resolving this
i am displaying a datagrid with some informations, say productid, unitprice,quantity.
i have a label which displays the subtotal of all the items displayed.
the datagrid has an option for delete.
if i delete one product, the subtotal is not changing.
can anyone please say, where is the problem in my code
page_load( )
If Not Page.IsPostBack Then
bindgrid()
End If
Dim total As Decimal = 0
Try
For Each dgi As DataGridItem In DataGrid1.Items
If dgi.ItemType = ListItemType.Item OrElse dgi.ItemType = ListItemType.AlternatingItem Then
Dim quantity As Integer = Integer.Parse(dgi.Cells(3).Text)
Dim unitprice As Decimal = Decimal.Parse(dgi.Cells(2).Text)
total = total + (unitprice * quantity)
End If
Next
Catch ex As Exception
End Try
lblsubtotal.Text = total.ToString("c")
lbltax.Text = (CInt(lblsubtotal.Text) * 0.06).ToString("c")
lblship.Text = (CInt(lblsubtotal.Text) * 0.15).ToString("c")
lblgrand.Text = (CInt(lblsubtotal.Text.ToString) + (lbltax.Text.ToString) + (lblship.Text.ToString)).ToString("c")
end sub
thanks
|