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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grid view Footer Grand total

Status
Not open for further replies.

mcallaghan

IS-IT--Management
Mar 22, 2005
43
0
0
US
I have a grid where I am doing a grand total it all works well but if the value can be null. When it is null it blows up. Does anyone know a work around.

<script runat="server">
Dim TotalUnitPrice As Decimal = 0.0
Function GetUnitPrice(ByVal Price As Decimal) As Decimal
If (GetUnitPrice Is Nothing) Then
Else
TotalUnitPrice += Price
Return Price
End If
End Function
Function GetTotal() As Decimal
Return TotalUnitPrice
End Function
</script>

This is the code in the gridview

<%#GetUnitPrice(Decimal.Parse(Eval("PO_Amt").ToString())).ToString("N2")%> </ItemTemplate>


Thanks
 
Simply add Price = 0 and TotalUnitPrice = 0 in the Nothing case.
 
Well I tried that It didnt work.

I think the issue has to do with the

Decimal.Parse(Eval(

Part of this code. It doesnt like the fact that the values are null.

Thanks
 
What error you're getting?

BTW, why do you need to parse? Can you just pass it without Decimal.Parse?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top