473,405 Members | 2,310 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,405 software developers and data experts.

Bind to ASP Table instead of Datagrid

I have a Class Module written in VB that calls an RPC (written in COBOL) we have written code to read the data from the RPC, and we create a temporary datatable to store the data from the RPC. This works fine when we call the datatable and bind it to a data grid using datagridname.DataBind(), but I have an ASP table, with calculations using tbl_name.row(1).cells(1) and the result of the calculation is put in a specific row and cell.

I have calculations throughout the table based on tbl_name.Rows(1).cells(1). I can't see how to do these types of calculations in a datagrid, and am not sure how to bind the datatabe to the ASP table. Can anyone help with either the bind to the datatable, or the way to calculate on a specific row and cell in a datagrid? Thanks for any help :-)

Coleen

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 18 '05 #1
6 5305
You won't be able to bind a datasource to an asp:table, it just doesn't have
a functionality, the web controls DataGrid/DataList were meant for that.
Here's what you can do though,

asp:table - you can create your own table from the datasource, and keep
track of values you need to calculate (I would suggest doing this if you are
doing some funky calculations within the table)

For the DataGrid, check into the OnItemDataBound property / ItemDataBound
event, you can look at any/all the data you want before it's actually bound
to the Datagrid, that way you can keep track of certain fields, and do
calculations, etc.

HTH,
--Michael

<coleenholley> wrote in message
news:eS**************@TK2MSFTNGP10.phx.gbl...
I have a Class Module written in VB that calls an RPC (written in COBOL) we have written code to read the data from the RPC, and we create a
temporary datatable to store the data from the RPC. This works fine when we
call the datatable and bind it to a data grid using datagridname.DataBind(),
but I have an ASP table, with calculations using tbl_name.row(1).cells(1)
and the result of the calculation is put in a specific row and cell.
I have calculations throughout the table based on tbl_name.Rows(1).cells(1). I can't see how to do these types of
calculations in a datagrid, and am not sure how to bind the datatabe to the
ASP table. Can anyone help with either the bind to the datatable, or the
way to calculate on a specific row and cell in a datagrid? Thanks for any
help :-)
Coleen

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest

Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 18 '05 #2
I could use the datagrid if I knew how to do the calculations for rows and columns...in other words, I need to multiply across and down:

row1.cell1 X row1.cell2 = row1.cell3

then I need the sum everytihing in column1 (which is cell1) as a grand total, sumofcolumn2(cell2) as a grand total and sumof column3(cell3) as a grand total.

I found an article on how to do the calculations as grand totals in a footer, but I can't find anything in VB on how to do the calculations across for row1.cell1 X row1.cell2 = row1.cell3

If you can provide me with a sample in VB of how to do the calculations across, I would be in your debt...

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 18 '05 #3
Could you do the calculations in your datasource?

sql for example
"Select column1, column2, column1*column2 as column3 from mytable"

<coleenholley> wrote in message
news:Od**************@TK2MSFTNGP11.phx.gbl...
I could use the datagrid if I knew how to do the calculations for rows and columns...in other words, I need to multiply across and down:
row1.cell1 X row1.cell2 = row1.cell3

then I need the sum everytihing in column1 (which is cell1) as a grand total, sumofcolumn2(cell2) as a grand total and sumof column3(cell3) as a
grand total.
I found an article on how to do the calculations as grand totals in a footer, but I can't find anything in VB on how to do the calculations across
for row1.cell1 X row1.cell2 = row1.cell3
If you can provide me with a sample in VB of how to do the calculations across, I would be in your debt...
---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest

Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 18 '05 #4
No, we are NOT using an SQL Database connection...the way we connect is part of the problem. To make a long story short, I can NOT do the calculation in an SQL statement, because I can't write an SQL statement to use in my connection. We use DB2 through a convoluded COBOL process. All my calculations have to be done on the Front end - in the web page. So I realy need a way to do calculations in the datagrid...thanks for any help

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 18 '05 #5
This is typically a straightforward process. In your itemdatabound event
handler you would do this
if(e.item.itemtype == listitem.item || e.item.itemtype ==
listitem.alternateitem)
e.item.cells[3].text = (Double.Parse(e.item.cells[1].text) *
Double.Parse(e.item.cells[2].text)).ToString()

There are a couple of issues here you need to be aware of. Parse will
explode on a null or empty value. Either check for null or empty, or wrap it
in a try catch block. Infact, the best way forward would be to use the
doubles tryparse functionality which avoids the penalty of an exception
The syntax is Double.TryParse. Here is an example:
double cell1=0, cell2=0;

if(Double.TryParse(e.Item.Cells[2].Text, NumberStyles.Number,
NumberFormatInfo.InvariantInfo, out cell1))

{

if(Double.TryParse(e.Item.Cells[2].Text, NumberStyles.Number,
NumberFormatInfo.InvariantInfo, out cell2))

{

e.item.cells[3].text = (cell1 * cell2).ToString();

}

}

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
<coleenholley> wrote in message
news:u5**************@TK2MSFTNGP12.phx.gbl...
No, we are NOT using an SQL Database connection...the way we connect is part of the problem. To make a long story short, I can NOT do the
calculation in an SQL statement, because I can't write an SQL statement to
use in my connection. We use DB2 through a convoluded COBOL process. All
my calculations have to be done on the Front end - in the web page. So I
realy need a way to do calculations in the datagrid...thanks for any help
---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest

Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 18 '05 #6
I really appreciate your help; however, I am programming VB.net, not C#. I'm sorry, but the example you sent me only confuses me...I know nothing about C#. Maybe you could send an example in VB? Thanks for your help :-

Coleen

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 18 '05 #7

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

Similar topics

7
by: Dan | last post by:
Very newbie question here: Any suggestions on how to bind an XML file to a combobox and datagrid? I've had no problem reading the data in a datagrid. But the combobox is another story. I...
6
by: Alpha | last post by:
I have several textboxes that I need to chang the text when the selection row is changed in a datagrid. I have the following code. This textbox displayes the initial selection but when I click on...
4
by: Greg Linwood | last post by:
I am wondering what the best approach to binding XML data to an asp:Table from the Page_Load event in a code behind module? I'm using VB.Net and initially approached this by adding a table to the...
3
by: AFN | last post by:
I need to manually create the data to be shown in a datagrid (or some data table object). Should I create an array and bind the array to the datagrid OR should I create a temporary dataset and...
2
by: Bennett Haselton | last post by:
I know how to create a DataAdapter that loads data from a data source into a table in a typed DataSet, and how to set the DataSource and DataMember properties of a DataGrid so that at run time it...
7
by: Jed | last post by:
I have a web service method that returns an array of custom objects marked serializeable with fully described public properties. When I bind the results to a DataGrid I can access the properties...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
3
by: serge calderara | last post by:
Dear all, Does anyone know how to bind a System.Collection.ArraysList object to a Dataset ? Thanks for your reply Regards Serge
3
by: PerumalSamy | last post by:
hi, i need details of how to bind two tables in a single datagrid for following example 1st row will be from 1st table next will be the rows from 2nd table in which the two table has...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
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,...
0
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...

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.