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

Loading a dtatgrid with values from another datagrid...

Hi all :-)

We are using a DB2 database connection through a class module to get the
data into a datagrid in an aspx web page using VB.Net. I can get the data
into the first datagrid with no problem, however, since I need to do a bunch
of calculations with these values AND pull values for two session variable
within the web application, I need to create another datagrid to display the
calculations. Here is what I'm doing:

dtg_stat_report_1.DataSource =
lo_AZRM010A.get_dt_stat_report_1
dtg_stat_report_1.DataBind()
For i = 0 To dtg_stat_report_1.Items.Count - 1
dgi = dtg_stat_report_1.Items(i)
ls_bus_name = dgi.Cells(0).Text
ls_gas_gal = dgi.Cells(1).Text.Trim.Replace(",",
"").Replace(" ", "").Replace(" ", "")
ls_gasohol_gal = dgi.Cells(2).Text.Trim.Replace(",",
"").Replace(" ", "").Replace(" ", "")
If ls_gas_gal = "" Then ls_gas_gal = "0"
If ls_gasohol_gal = "" Then ls_gasohol_gal = "0"
li_gas_gal = CInt(ls_gas_gal)
li_gasohol_gal = CInt(ls_gasohol_gal)

li_st_1265_tax = (li_gas_gal + li_gasohol_gal) *
0.12397
li_st_5_tax = (li_gas_gal + li_gasohol_gal) * 0.049
li_cty_535_tax = (li_gas_gal + li_gasohol_gal) *
0.05243
li_cty_opt_tax = Session("tot_cty_opt_tax")
li_cty_1_tax = (li_gas_gal + li_gasohol_gal) *
0.0098
li_CPI_tax = Session("wa_tot_gal")

dtg_display.DataSource = of_ref_table()
dtg_display.DataBind()
'Fill the variables in dtg_display with the values
from above
For j = 0 To dtg_display.Items.Count - 1
dtg_display.Items(1).Cells(0).Text = ls_bus_name
dtg_display.Items(1).Cells(1).Text = ls_gas_gal
dtg_display.Items(1).Cells(2).Text =
ls_gasohol_gal
dtg_display.Items(1).Cells(3).Text =
li_st_1265_tax
dtg_display.Items(1).Cells(4).Text = li_st_5_tax
dtg_display.Items(1).Cells(5).Text =
li_cty_535_tax
dtg_display.Items(1).Cells(6).Text =
li_cty_opt_tax
dtg_display.Items(1).Cells(7).Text =
li_cty_1_tax
dtg_display.Items(1).Cells(8).Text = li_CPI_tax

Next

The of_ref_table() creates the columns for the new datagrid, but I cannot
get the values to populate. I know I need to do something like
dtg_display.row(i).add, but this is not available to me. Any suggestions?
TIA,

Coleen
Nov 20 '05 #1
5 1365
Hi Coleen,

A couple things...first, the best way to fill a data grid is directly from a data source. Try filling your second data grid from a data table or data view instead of from the first data grid.

Also, you've probably already caught this, but your second For...Next loop never makes reference to your index counter (j), so it is just overwriting the first row multiple times.

Take care,

Eric
Nov 20 '05 #2
Hi Eric - Thanks - I had not caught that yet, I've been side tracked on
something else...the problem we have with getting our data directly from a
data source is the way we connect to the DB2 database using class modules.
I have to populate the page in the code behind from the values in the first
datagrid because we can't pull session variables in the class module, thus I
have to do all my calculations and get my session variables in the code
behind. If I can create a dataview instead of a datagrid that would be
great, since I don't want to display the first datagrid any ways. I will
try that...Thanks again :-)

"Eric Lemmon" <E_********************@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi Coleen,

A couple things...first, the best way to fill a data grid is directly from a
data source. Try filling your second data grid from a data table or data
view instead of from the first data grid.

Also, you've probably already caught this, but your second For...Next loop
never makes reference to your index counter (j), so it is just overwriting
the first row multiple times.

Take care,

Eric
Nov 20 '05 #3
Sounds good. Also, a "heads up" on your calculations...

You might want to reference the underlying data table instead of your data view when number crunching. This cuts out the "middle man", so you can streamlined your performance a bit (pardon the cliché). The data view will need to reference the data table anyway, so that is at least one less registry (at least) per calculation to use during processing.

Another common problem with data views is maintaing synchronization between that and the underlying table. When you add/delete the rows using a data view, it can easily throw off the indexing when the binding context position changes (until the data source is update). Hitting the table directly can mostly take care of this.

Take care,

Eric
Nov 20 '05 #4
Thanks very much for the heads up and the advice, I appreciate it :-)
"Eric Lemmon" <E_********************@hotmail.com> wrote in message news:O4**************@TK2MSFTNGP11.phx.gbl...
Sounds good. Also, a "heads up" on your calculations...

You might want to reference the underlying data table instead of your data view when number crunching. This cuts out the "middle man", so you can streamlined your performance a bit (pardon the cliché). The data view will need to reference the data table anyway, so that is at least one less registry (at least) per calculation to use during processing.

Another common problem with data views is maintaing synchronization between that and the underlying table. When you add/delete the rows using a data view, it can easily throw off the indexing when the binding context position changes (until the data source is update). Hitting the table directly can mostly take care of this.

Take care,

Eric
Nov 20 '05 #5
No problem. :-)
Nov 20 '05 #6

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

Similar topics

0
by: Gamze | last post by:
Hi, How can i get values from datagrid to combobox and should select the same name as in datagrid row on the combobox control In my vb.net windows application ,i have combobox which is...
2
by: Balamurukan | last post by:
How to retrive property values from our own property window
5
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. ...
1
by: Sundaresan | last post by:
I've a form where I load two user controls dynamically. User Control-1 has a no.of dropdowns and based on the selection I typically populate a datagrid in the user control-2, Also the I could...
4
by: blackhawk | last post by:
I need to build a web page that has to potentially display a large amount of data in two grids on the same page. The HTML file with all of the formatting is about 7MB in size. This is too large...
1
by: Bala | last post by:
Hi, Currently i am loading the file names into datagrid (unbound) from a folder(sub folders too). so for this i am using this below code. but its too slow to loading all the file names. is it...
7
by: GaryDean | last post by:
I'm trying to load a GridView up with data manually, in code. I'm not using any datasource. Using this code.... ArrayList myRowArrayList; GridViewRow myGVR = new...
8
by: stephen | last post by:
Hi, I make use of properties to store values that are relevant to the page but this time I am posting the page to itself and the values are Zero or null (they disappear). is there any other way...
8
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their report...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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
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.