Calculated column from columns in same row??


Hi everyone -
Is there a way to display a calculated value
in a column based on values from the same row?

Using a datagrid
thanks
tony
0
pithhelmet
6/14/2004 4:10:18 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
778 Views

Similar Articles

[PageSpeed] 33

Sure. Have a function declared for your OnItemDataBound:


Sub CalculateValues(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
dim total as Integer = CType(e.Item.FindControl("col1"), Integer) + CType(e.Item.FindControl("col2"), Integer)
e.Item.FindControl("totalCOlumn").Text = total
End Sub

I think it would be something like that.
Sara
http://www.ilovecode.com
0
ses5909
6/14/2004 4:33:49 PM
If you can change the data coming from the database, check out this article by Dino Esposito:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndive/html/data01102002.asp
If not, check out these code samples on ASPAlliance:
http://authors.aspalliance.com/olson/articles/summary.aspx
Darrell Norton, MVP
Darrell Norton's Blog


Please mark this post as answered if it helped you!
0
DarrellNorton
6/14/2004 5:04:35 PM
Reply:

Similar Artilces:

How to go through a datatable row by row and column by column
Hello, I have a dataset with a datatable and I need to insert each row from the datatable on my sql table, anyway there may be errors, so some rows may not be inserted because primary key constraints,  So I need to show the rows that are not inserted in a gridview, the hard thing to do is to go through all the datatable,  is there an wasy way to do it?MCPD ENTERPRISE APPLICATION DEVELOPER Start by looking herehttp://msdn2.microsoft.com/en-us/library/system.data.common.dataadapter.update.aspxPerform an update of your dataset, and if a row fails, you can mark it as invalid.You can ...

When is a column not a column?
I have several extremely similar datawindows that I have to maintain that go against the same table. Recently, I had to add a column to that table, and also add the column to ALL of these datawindows that go against this table. I added the column to the first datawindow, set up the edit control style, etc. I then did a copy/paste of the columns edit control to the remaining dw's (of course remembering to first add the column in SQL). Everything (update props, column specs, column props) seems to indicate that the pasted column is linked to the column I selected, HOWEVER, when I...

to Calculated Columns, then to update another column in same table in ADO.NET
to get several Columns, then pass those Columns into  one function which will return  a result,then using the result to update another column in same table in ADO.NET, How can I do this? thanks. Hi   what ever information you given is not clear. so please give me  detail info.Ganesan  Clarity is required. Plz explain clearly wts u r requirement.Thank uBaba Thank uBabaPlease remember to click "Mark as Answer" on this post if it helped you. ...

computing the difference of a column in the current row from the column of the preceding row
Hello, a user asked me if we can solve following problem: we want to compute the difference (delta) of a column in the current row from the column of the preceding row. My first solution signs where: create a computed field (small_function_result) that takes the value from the preceding row: small(value, value, cf_getrow for all); where cf_getrow is a computed field like this: if(getrow()=1,getrow(),getrow()-1) create a computed field (Diff) that computes the difference: value-small_function_result My results should look like this: Row Value cf_getrow small_func...

GridView.Rows(Column=ID_PK) to GridView.Rows(Column=DropDownListTeamplteField)
Hi Guys,I wonder how I can assign the PrimaryKey in each GridView Row to the template field in the same row. whereas the template field is filled with a dropdownlist thatshould show the values for retrieved in a different table through the GridView Row primary key (which serves as the SELECT parameter to get these values) The GridView looks like this:<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="C_ID" DataSourceID="GetC_IDs"> <Columns> <asp:BoundField D...

SQL: mutiple rows one column to multiple columns one row
In InfoMaker SQL can you take a table with multiple rows for the same key and take a column from the rows and create mutiple columns with one report line with the key(no duplicate keys) on a report? For example Table books (key) (book title) 123 misery 123 titanic 123 roots 456 war 456 1984 456 giant The report I need would look like this Key title1 title2 title 3 123 misery titanic roots 456 war 1984 giant Thanks in advance. -- Kaye Hendry HealthInsight email:kaye.hendry@healthinsight.org ...

Is there a control that offers the same data presentation as a GridView, but allows users to copy and paste many rows/columns at once?
 Hi Is there a control that offers the same data presentation as a GridView, but allows users to copy and paste many rows/columns at once onto the grid? What I mean is some grid that 's as flexible as MS Excel grid for example.  Any suggestions will be very much appreciated.E The Repeater control is a highly customisable data presentation controlRohin.NET developerNever trust a computer you can't throw out a window. - Steve WozniakPlease remember to click on 'Mark as answer', if this post helped you......

How to divide 1 GridView Row with 1 column in 2 Rows with 5 columns?
Hi; I have a GridView with 10 rows and 1 column. How can I do to this GridView show the same data, but with 2 rows and 5 columns? In classic ASP, I made it this way: While (NOT rsFotos.EOF) if i mod 5 = 0 then Response.Write "</tr><tr>" end if ... Someone can help? :)  You have to use a custom template and lay the table out the way you want, either dropping controls in the template or creating a custom ITemplate that takes care of it for you. http://professionalaspnet.com/archive/2006/06/15/Useing-ITemplate-in-the-Data-Controls.aspxChris L...

How can I display multiple rows w/8 columns (4 columns editable on each row)?
Hello, Please - Can anyone suggest the best way to display a joined dataset with 4 read-only columns, 4 editable columns and a checkbox column? The content for this display currently has < 100 rows - but could approach 1000 in the future. I currently have this setup with a Datagrid (working) - but I would like to be able to edit the 4 columns of ALL rows in the displayed list instead of one row at a time as the Datagrid allows. After editing, I use an update function to traverse the modified list/table and save all values that have the Checkbox clicked. Could a list with 10...

is it possible to turn 1 column,many rows into one row,many columns in sql ?
 Hi AllI have the following query:Select CategoryName From Category Where CategoryId In(Select SkillId From SpecialitySkills Where CopywriterId = 13) It gives me the correct results but not in the form that i want, i would like it to be in one row, many columns. its in 1 column, many rows.Any ideas?  You must be talking about displaying it on a web page? Just create a loop that runs through the rows of the data that is returned then just make html table:dim tablestring as string = "<table><tr>" for i as integer = 0 to dt.rows.count - 1 tablestring += &...

Column Name in datastore ( invalid row/column ....)
--------------A15DFE08B1A7F5CB43BA4D7D Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I have a problem with a script, when i reference the column name of a datastore with GetItem.... function. I'm using PB 5.03 and MS SQL 6.5. This is the sql syntax for generating datastore. sql_syntax_ac = "SELECT tabmer.mer_code, tabmer.mer_desc, tabreg.reg_code, tabreg.reg_desc, "+& "Sum(tabarc.arc_rine - tabarc.arc_reso) 'fatturato', "+& "Sum(tabarc.arc_cove - tabarc.arc_core ) 'costo...

validation columns against column
Hi  Do anybody know some articles or codeexample of how to validate columns against a input Column. B can be > A and B can be < C. If you in row ID write 55 for Column_B, it must be reject.example:ID        column_A  Column_B   Column_C1              3               10             152         &...

Dividing one column to 4 columns in the Repeater control
Hi Folks, The following is my Repeater-Control code that providing a list of 20 companies names. I'm getting all of the data in one long column and I would like to divide this one column to 4 columns. Is it possible? how can I do it in my code: <asp:Repeater ID="catlist" runat="server"> <HeaderTemplate> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> ...

Writing a column after column
Hi all, I need to consolidate columns of data available across different directories into a single excel csv file. Usually we write to a file row after row but for the current task I have, it would be convenient to write the file column after column. Is there a file writing mode for this? If not, I guess, I will have to write the matrix row by row and then take a transpose. Let me know what you guys think and if you could share some skeleton of code for something like this would be great. Thanks. -vijay vijay wrote: > I need to consolidate columns of data available acro...

Web resources about - Calculated column from columns in same row?? - asp.net.presentation-controls

Calculated Risk - Wikipedia, the free encyclopedia
^ Streitfeld, David (December 1, 2008). "Doris Dungey, Prescient Finance Blogger, Dies at 47" . New York Times. p. A27, New York edition . h ...

Image from page 12 of "The American anti-slavery almanac, for ... : calculated for Boston, New York ...
Identifier: americanantislav1838chil Title: The American anti-slavery almanac, for ... : calculated for Boston, New York, and Pittsburgh .. Year: ...

Cosy deal calculated to aid fund managers
A few years back, the corporate regulators did the fund managers a big favour.

Paris shooting: Charlie Hebdo gunmen were not crazy, just calculated
Sometimes crazy men are not crazy; not in any clinical sense. Some crazy men do what they do because they make a cold and reasoned decision that ...

Joe Hockey's change of heart on uni fees is calculated
Thank you, Waleed Aly, for your eye-opening article ("Gotcha politics is just light entertainment", May 30). It would be hypocritical not to ...

Taylor Swift is terribly calculated and mean, says Grizzly Bear's Edward Droste
The lead singer from Brooklyn indie band Grizzly Bear has taken down Taylor Swift on Twitter and admitted to being genuinely scared of the successful ...

Canterbury Bulldogs' calculated leap of faith in Michael Lichaa places weight of expectation on his shoulders ...
Even the expectation of bursting into the NRL as the hottest rookie in the game could not have prepared Michael Lichaa for what would unfold ...

Keystone XL Emissions Could Be Four Times Higher Than U.S. Calculated, Says New Study
WASHINGTON - The much-debated Keystone XL pipeline could produce four times more global warming pollution than the State Department calculated ...

Size matters, but so does how it is calculated
Size matters, but so does how it is calculated

Stop Giving Away the Store: “Reasonably Calculated” does not define the scope of discovery. (And it never ...
For over a hundred years Americans have enjoyed Josh Billing’s chestnut, “I’d rather not know so much, than to know so much that ain’t so.” ...

Resources last updated: 12/25/2015 7:26:10 AM