473,387 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How do I put computed values in 'formview'

I have a formview control, with labels arranged in a table. The
labels are bound to fields from a query. But I also want to sum up
the values in the table and put them in a row of totals at the bottom.
What I find is that the labels in the table are not accessible from
the code-behind page.
I'd like to do something like this:
lblTotal.text = cint(lblrow1.text) + cint(lblrow2.text) etc.
But the codebehind doesn't recognize the labels. Maybe thats because
they are within a formview.
Is there any way to compute totals within a formview?
Thanks,
Marvin
Jun 27 '08 #1
2 2304
Check out the FindControl method for the FormView
David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
<CO*********@lycos.comwrote in message
news:26**********************************@y21g2000 hsf.googlegroups.com...
>I have a formview control, with labels arranged in a table. The
labels are bound to fields from a query. But I also want to sum up
the values in the table and put them in a row of totals at the bottom.
What I find is that the labels in the table are not accessible from
the code-behind page.
I'd like to do something like this:
lblTotal.text = cint(lblrow1.text) + cint(lblrow2.text) etc.
But the codebehind doesn't recognize the labels. Maybe thats because
they are within a formview.
Is there any way to compute totals within a formview?
Thanks,
Marvin

Jun 27 '08 #2
On 5 May, 21:54, COHENMAR...@lycos.com wrote:
I have a formview control, with labels arranged in a table. *The
labels are bound to fields from a query. *But I also want to sum up
the values in the table and put them in a row of totals at the bottom.
What I find is that the labels in the table are not accessible from
the code-behind page.
I'd like to do something like this:
lblTotal.text = cint(lblrow1.text) + cint(lblrow2.text) etc.
But the codebehind doesn't recognize the labels. *Maybe thats because
they are within a formview.
Is there any way to compute totals within a formview?
Thanks,
Marvin
That would be one way of doing it - you could put code in the
RowDatabound event handler and access the content of the labels with
e.item.FindControl()

There are easier and more efficient ways to do it though!

For example

(1) Create an expression for the databinding of the results label
like this

<asp:label ... text='<%# Eval(Value1) + Eval(Value2) ... %>' ...

(2) do it in the query itself -

Select Value1, Value2, Value1 + Value2 as Value3 ...

then bind the label destined to display the result to the column named
Value3

HTH
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Michael Glass | last post by:
I'm working on an ASP.Net web app using VS2005 and the .Net 2.0 framework, and I have a serious problem with the page I'm currently working on. The page has, among other things, two FormViews and a...
2
by: Gary Homewood | last post by:
Where can I specify a default value for a column when using a FormView? Specifically, I have a checkbox for a column of bit datatype on my database, and I'd like to default it to checked for insert...
0
by: Hawk | last post by:
Hello, this is my first post hope to get some good answers. I am using asp.net 2.0 and I am trying to pass the value entered in the formview textbox in insert mode "in this case it is the...
0
by: Prakash | last post by:
Hi all, I am getting an error message "Object reference not set to an instance of an object." when i try to read values that are inside FormView control. I am just trying to read the values...
7
by: Aamir Mahmood | last post by:
Hi All I have DataTable object. Is there a way that I can know which fields (columns) in the table are computed. Apparantly the DataTable.Columns returns all columns both computed and other....
2
by: Matt MacDonald | last post by:
Hi all, I'm having an issue that's driving me crazy. I have a datatable that I need to display all the information for on a page. So, instead of manually coding every single column to a label, I...
2
by: GTalbot | last post by:
Hello fellow comp.infosystems.www.authoring.stylesheets colleagues, Imagine this situation: #grand-parent-abs-pos { height: 400px; position: absolute; width: 600px; }
4
by: pankajsingh5k | last post by:
Hi guys, These question is for all the experts... Please help me before my brain explodes The problem is again with the formview control.. I have a formview and i have to use it that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.