Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Formatting output fron Helper Function in Template? Syntax?

Reply
Thread Tools

Formatting output fron Helper Function in Template? Syntax?

 
 
D. Shane Fowlkes
Guest
Posts: n/a
 
      05-19-2005
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>



 
Reply With Quote
 
 
 
 
Marina
Guest
Posts: n/a
 
      05-19-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What's the purpose of the helper cache and is there a way to just turn off helper cache-ing? kevin Ruby 1 07-21-2006 03:42 AM
Passing an integer aray fron a c func ss Java 1 06-22-2006 06:20 AM
Conversion fron signed to unsigned? Bill C Programming 2 09-13-2005 03:35 PM
muti printer use fron one PCc Piemanlager Digital Photography 3 03-02-2005 05:35 AM
converting fron unsiged char to int Joseph Suprenant C++ 4 08-19-2003 10:55 PM



Advertisments