473,467 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1588
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Isaac Councill | last post by:
Hello, This seems like a newbie question, but I couldn't find the answer on google. I've been using xsl to transform rdf files into runnable programs in another (non-markup) language. It's...
0
by: Dimitre Novatchev | last post by:
You seem to be unaware of the xslt processing which uses the built-in rules in the absence of templates that match some selected node. http://www.w3.org/TR/xslt#built-in-rule According to the...
7
by: CSpartan | last post by:
I need to create a C++ function that works similar to 'cout'. I would like to have a function 'MyTextOut' that would accept the following syntax MyTextOut << "x = " << iX << " kg" ; and...
8
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At...
4
by: hope | last post by:
Hi, How can I format a string field using Data Formatting Expression property in datagrid? For example: format last name from BROWN to Brown. Thanks
3
by: washoetech | last post by:
I have a gridview control. In this grid view there is a column for the price of an item. Some of the prices have a dollar sign in front of it and some dont. How do I get rid of the dollar sign...
3
by: yuvalif | last post by:
I want to get rid of my "sprintf" call, so I wrote the following example, in which I have two problems: (1) why do I need to inherit from "streambuf", and not just use it as a local in my "ToBuff"...
11
by: Dustan | last post by:
Is there any builtin function or module with a function similar to my made-up, not-written deformat function as follows? I can't imagine it would be too easy to write, but possible... 'I am...
4
by: aaragon | last post by:
Hi everyone, I was unable to find out why my code is not compiling. I have a template class and I'm trying to write the operator<< for standard output. Does anyone know why this is not right?...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.