Using both static data and data from some GridView cells I am attempting to calculate a result in a Template Cell - but to no avail!
The value for TextBox1 is brought in on the page_load event and I'm attempting the balance of the calculation uisng the ItemDataBound event :- -
-
Protected Sub GridView1_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
-
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
-
Dim vInterest As Single = TextBox1.Text / 100.0#
-
Dim vRate As Single = 1.0#
-
Dim vRemLife As Single = e.Item.Cells(3).Text
-
Dim vCostAv As Single = e.Item.Cells(4).Text
-
Dim vNum As Integer
-
For vNum = 1 To vRemLife
-
vRate = vRate * (1 + vInterest)
-
Next vNum
-
Dim vInsert As Single = Format(vCostAv * vRate, "###.##.0.00")
-
e.Item.Cells(5).Text = vInsert
-
End If
-
-
But the calculated cells are always empty at run time! Any ideas what where I'm going wrong?
3 1745
Have you stepped through the code to make sure it's doing what you expect, and when you expect it?
Have you stepped through the code to make sure it's doing what you expect, and when you expect it?
I re-jigged it - and now it works :-) -
-
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
-
If e.Row.RowType = DataControlRowType.DataRow Then
-
Dim vInterest As Single = TextBox1.Text / 100.0#
-
Dim vRate As Single = 1.0#
-
Dim vRemLife As Single = Convert.ToSingle(DataBinder.Eval(e.Row.DataItem, "Rem_Life"))
-
Dim vCostAv As Single = Convert.ToSingle(DataBinder.Eval(e.Row.DataItem, "Cost_Av"))
-
Dim vNum As Integer
-
For vNum = 1 To vRemLife
-
vRate = vRate * (1 + vInterest)
-
Next vNum
-
Dim vInsert As Single = vCostAv * vRate
-
Dim vInsert2 As String = Format(vInsert, "###,##0.00")
-
e.Row.Cells(6).Text = vInsert2
-
End If
-
End Sub
-
-
Ok. Glad to see you've resolved it.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Miguelito Bain |
last post by:
hi everybody.
i'm trying to find out what you can and can't do with/in calculated
fields. any help, pointers, and/or advice would be greatly
appreciated. i'm a newbie, but i want to learn, and i've tried a lot
before posting.
here's my situation.
i have a simple form with dates on it. i have an indate and outdate
|
by: Jon S via DotNetMonster.com |
last post by:
HI all,
I'm returning a dataset to a gridview control. When the gridview asp.net
control is populated from the returning dataset some of the cells remain
empty. This is expected as some data in the dataset is empty. The cells
that are empty, in the gridview control, I would like to have the value of 0
(zero) inserted. Is there a default cell value property or something similar
for the asp.net gridview control. So if no data is...
|
by: markm75c |
last post by:
Does anyone know of a way to sort a column which isnt databound or an
actual field in the database, but is derived from a method?
IE. I have a grid showing stats for softball, with a calculated field
called AVG, I want to be able to sort based on AVG when they click on
AVG.
I can't seem to find a way to do this out there.
Thanks!
|
by: K B |
last post by:
I would like to create a gridview as below:
Project Name 1-1 1-2 1-3 1-4 1-5 1-6
Project 1 BLUE BLUE BLUE BLUE GREEN GREEN
more projects
I would like to fill the cell with a solid color based on the value of
the cell (e.g., documents that are complete (blue) or not complete
(green). In effect have a solid bar indicator going across each row. I
know how to color the cell based on the value, but not the click...
|
by: =?Utf-8?B?TWlrZQ==?= |
last post by:
Hi,
I can return the rowindex using SelectedRow or SelectedIndex
But, how do I get my code to return the cell or column index of a selected
row in my gridview?
thanx
--
Regards,
| |
by: Bill Gower |
last post by:
I have an cell which contains a field member which is filled with
String.Empty. When I retrieve the value in the cell with
Cells.Text.ToString() and try to compare it to String.Empty, I can't
because it contains " ". I really don't want to compare the value to
that so how can I retrieve an empty cell so that it is String.Empty.
Bill
|
by: =?Utf-8?B?TWlrZQ==?= |
last post by:
Hi,
I've bind a grdiview to a database and it's working fine. but what I want
to do is if the data in certain cell exceed the cell width the that cell will
only show the words with some dots implying to the user that is more data
that should be seen.
meaning that if the data to be shown in a cell is e.g: "This is my data an
it's very long that why I'm showing it all" I would like cell just showing
the first words followed by dots like...
|
by: Mike |
last post by:
I have a gridview that has a button in the last cell of each row. I want to get the text from cell 1 for that row the button was clicked on.
So if my gridview looks like this:
N-12 BMW
N-35 Mercedes
if my user clicks row 2, I want to see Mercedes, How can I do that?
I have a buttonClick event for my select button, I'm trying to pull the values using the DataKeyName, but I keep getting 'object reference...
|
by: foolmelon |
last post by:
Before AJAX, we were able to focus a cell in a gridview during a
fullpage postback. After putting the gridview inside an UpdatePanel,
we cannot focus a cell in this gridview anymore. Does anybody know if
it is possible to make such focus? Thanks!
Bill
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 we have to send another system
| |