469,345 Members | 6,349 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,345 developers. It's quick & easy.

Formatting output fron Helper Function in Template? Syntax?

Hey guys. I have a Repeater and a Template. One of the dataitems calls a
helper function. The dataitem sends the record ID to the function and the
function runs a complex query and returns a calculation which is a dollar
amount. The ID is a "construction project" and the helper function goes and
determines how much money has already been spent against the project by
querying expenditure tables.

The function works fine but how can I format the output to be currency? I
also noticed that even though my function returns data of a Decimal type, it
seems to come out as a Integer. No "cents" are written to the page.

Thanks!

(In VB)

<code>

Function CalculateExpended(intBudgetID As Integer) As Decimal

Dim objConnection As SqlConnection
Dim cmdSelectData As SqlCommand
Dim strConnectString As String
Dim strSQL As String
Dim decExpendedAmt As Decimal

strConnectString =
System.Configuration.ConfigurationSettings.AppSett ings("SqlConnection")
strSQL = "SELECT Stuff....."
objConnection = New SqlConnection(strConnectString)
cmdSelectData = New SqlCommand(strSQL, objConnection)

objConnection.Open()
decExpendedAmt = cmdSelectData.ExecuteScalar()
objConnection.Close()

Return decExpendedAmt

End Function

In Template....

Expended: <%# (CalculateExpended(Container.DataItem("ID"))) %>

</code>

Nov 19 '05 #1
1 1422
Here you are relying on however .NET natively formats decimals.
To format as currency, you function should either do the formatting and
return a string, or in your script block, you should wrap your call out to
the function in something that will do the formatting.

"D. Shane Fowlkes" <sh**********@hotmail.com> wrote in message
news:O9**************@TK2MSFTNGP09.phx.gbl...
Hey guys. I have a Repeater and a Template. One of the dataitems calls a
helper function. The dataitem sends the record ID to the function and the
function runs a complex query and returns a calculation which is a dollar
amount. The ID is a "construction project" and the helper function goes
and determines how much money has already been spent against the project
by querying expenditure tables.

The function works fine but how can I format the output to be currency? I
also noticed that even though my function returns data of a Decimal type,
it seems to come out as a Integer. No "cents" are written to the page.

Thanks!

(In VB)

<code>

Function CalculateExpended(intBudgetID As Integer) As Decimal

Dim objConnection As SqlConnection
Dim cmdSelectData As SqlCommand
Dim strConnectString As String
Dim strSQL As String
Dim decExpendedAmt As Decimal

strConnectString =
System.Configuration.ConfigurationSettings.AppSett ings("SqlConnection")
strSQL = "SELECT Stuff....."
objConnection = New SqlConnection(strConnectString)
cmdSelectData = New SqlCommand(strSQL, objConnection)

objConnection.Open()
decExpendedAmt = cmdSelectData.ExecuteScalar()
objConnection.Close()

Return decExpendedAmt

End Function

In Template....

Expended: <%# (CalculateExpended(Container.DataItem("ID"))) %>

</code>

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Isaac Councill | last post: by
reply views Thread by Dimitre Novatchev | last post: by
7 posts views Thread by CSpartan | last post: by
4 posts views Thread by hope | last post: by
3 posts views Thread by washoetech | last post: by
3 posts views Thread by yuvalif | last post: by
11 posts views Thread by Dustan | last post: by
4 posts views Thread by aaragon | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.