472,378 Members | 1,498 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,378 software developers and data experts.

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 1530
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?...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
by: F22F35 | last post by:
I am a newbie to Access (most programming for that matter). I need help in creating an Access database that keeps the history of each user in a database. For example, a user might have lesson 1 sent...

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.