473,659 Members | 2,965 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple Math in Gridview

Newbie here trying to learn.

Using VS2005 / learning in VB.NET for an ASPX page.

Sorry for this simple question. I have a Gridview1 with 2 columns. I added
a 3rd column and all I want to do is add the numbers in the 1st and 2nd
column together for the 3rd column. Can someone tell me where I can put the
code in Visual Studio 2005 and how I tell the Gridview to do the simple
math?

Is there a site that will teach me exactly this? I googled but didn't find
exactly this.
Sep 22 '06 #1
1 2115
Hi,
Here is a simple way to do what you are looking for
<script runat="server">
void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add( "FirstColumn",t ypeof(int));
dt.Columns.Add( "SecondColu mn", typeof(int));
DataRow dr = dt.NewRow();
dr["FirstColum n"]=34;
dr["SecondColu mn"]=12;
dt.Rows.Add(dr) ;
dr = dt.NewRow();
dr["FirstColum n"]=7;
dr["SecondColu mn"]=4;
dt.Rows.Add(dr) ;

grd.DataSource= dt;
grd.DataBind();
}
}

</script>
<asp:GridView runat="server" ID="grd" AutoGenerateCol umns="false">
<Columns>
<asp:BoundFie ld DataField="Firs tColumn" HeaderText="Fir st" />
<asp:BoundFie ld DataField="Seco ndColumn" HeaderText="Sec ond"
/>
<asp:TemplateFi eld HeaderText="Sum ">
<ItemTemplate >
<%# ((int)Eval("Fir stColumn"))
+((int)Eval("Se condColumn")) %>
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>
</asp:GridView>
"Phillip Vong" wrote:
Newbie here trying to learn.

Using VS2005 / learning in VB.NET for an ASPX page.

Sorry for this simple question. I have a Gridview1 with 2 columns. I added
a 3rd column and all I want to do is add the numbers in the 1st and 2nd
column together for the 3rd column. Can someone tell me where I can put the
code in Visual Studio 2005 and how I tell the Gridview to do the simple
math?

Is there a site that will teach me exactly this? I googled but didn't find
exactly this.
Sep 22 '06 #2

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

Similar topics

1
2536
by: barnesc | last post by:
Hi! Here's a simple hashcash implementation in Python. 28 lines of actual code. Can be reduced to 17 lines for instructional purposes, if you don't want clustering, and use xrange() instead of irange().
2
1647
by: Senraba | last post by:
I would like to have a 600 X 400 window open with search results from CPanel's Entropy Search form. I have the following in the <HEAD> tag: <script language="javascript" type="text/javascript"> <!-- var win=null; function NewWindow(mypage,myname,w,h,scroll,pos){ if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
2
1357
by: Webdiyer | last post by:
Hi, We all know that the return value of Math.Log(8,2) is 3,but how about (int)Math.Log(8,2)? On my machine,the return value of (int)Math.Log(8,2) is strange enough! it's not 3 but 2 ! I've tested other values such as (int)Math.Log(16,2),(int)Math.Log(4,2),(int)Math.Log(32,2)...et, they all return the same value as their counterpart Math.Log() methods,only (int)Math.Log(8,2) is incorrect,is this a .net bug ? I've also tested...
3
2141
by: vezquex | last post by:
What I want is an element with a shifting background image: <html><head> <script type="text/javascript"> var x = 0 var y = 0 inc = 4 function bgWander(el){ x = x + Math.round(2*inc*Math.random())-inc y = y + Math.round(2*inc*Math.random())-inc
2
2016
by: Phillip Vong | last post by:
Sorry about this simple question. I'm running ASP.NET 2.0 using VS2005. I have a simple Gridview. I have a column named "WhoUpdate" with visible = False. <asp:BoundField DataField="WhoUpdate" HeaderText="WhoUpdate" SortExpression="WhoUpdate" Visible="False" />
1
1575
by: macklin01 | last post by:
Hi, everybody. I'm trying to do some last cleaning up on the following php page I wrote: http://www.math.uci.edu/~pmacklin/Publications.php This URL parses an XML file of publications: http://www.math.uci.edu/~pmacklin/Publications.xml
10
1980
by: Ron | last post by:
I want to calculate the surface area of a sphere from an inputed radius with option strict on. I guess I am not converting something correctly. Here is what I am doing: I have a textbox txtradius that I enter a radius into. I then have a lable that I want the surface area to be displayed in called lblsurface
5
1709
by: gray_slp | last post by:
I am designing a web survey using surveymonkey.com and discovered I could use javascript to modify their standard question formats much the same as can be done in myspace. I used this feature to insert a weight converter into my survey. Unfortunately this script works fine in firefox v.2 but does not cooperate with the surveymonkey software when used with internet explorer v.6. Can someone explain to me in simple terms why the script...
22
2774
by: giordan | last post by:
Hi all! I've wrote this code: <script type="text/javascript"> var largImg; var altImg; var txtTop = '<b>Ottima scelta!</b> Ora compila il form e premi "Ricevi banner". Il codice HTML ti verrà mostrato in questa pagina e, per comodità, ti verrà inviato, via mail, all\'indirizzo da te fornito. Se invece vuoi cambiare il banner premi "Seleziona banner"'; var txtButton = 'Cambia banner'; var testo = '';
0
8428
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, 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...
0
8335
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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, 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...
0
8747
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 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...
0
7356
agi2029
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...
1
6179
isladogs
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...
0
5649
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
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...
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.