473,703 Members | 2,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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).Te xt
ls_gas_gal = dgi.Cells(1).Te xt.Trim.Replace (",",
"").Replace (" ", "").Replace("&n bsp;", "")
ls_gasohol_gal = dgi.Cells(2).Te xt.Trim.Replace (",",
"").Replace (" ", "").Replace("&n bsp;", "")
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_ct y_opt_tax")
li_cty_1_tax = (li_gas_gal + li_gasohol_gal) *
0.0098
li_CPI_tax = Session("wa_tot _gal")

dtg_display.Dat aSource = of_ref_table()
dtg_display.Dat aBind()
'Fill the variables in dtg_display with the values
from above
For j = 0 To dtg_display.Ite ms.Count - 1
dtg_display.Ite ms(1).Cells(0). Text = ls_bus_name
dtg_display.Ite ms(1).Cells(1). Text = ls_gas_gal
dtg_display.Ite ms(1).Cells(2). Text =
ls_gasohol_gal
dtg_display.Ite ms(1).Cells(3). Text =
li_st_1265_tax
dtg_display.Ite ms(1).Cells(4). Text = li_st_5_tax
dtg_display.Ite ms(1).Cells(5). Text =
li_cty_535_tax
dtg_display.Ite ms(1).Cells(6). Text =
li_cty_opt_tax
dtg_display.Ite ms(1).Cells(7). Text =
li_cty_1_tax
dtg_display.Ite ms(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 1383
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_************ ********@hotmai l.com> wrote in message
news:%2******** ********@tk2msf tngp13.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_************ ********@hotmai l.com> wrote in message news:O4******** ******@TK2MSFTN GP11.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
1994
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 populated by sqlserver database table.When i select value from combobox ,value saved in to other table of my database and i use to datagrid to show this table.
2
2010
by: Balamurukan | last post by:
How to retrive property values from our own property window
5
12236
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. The ID is a member of the keys array. I then create a DataView dv over the table, and sort it by Display and ID column (in case of duplicate Display). I then set my DataGrid.DataSource = dv; I then load the datatable with my rows, and this is...
1
1461
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 be loading a different usercontrol-2 based on the selections in usercontrol-1. Also I thought of passing the selection values through
4
3281
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 and I need to implement some kind of "client side" lazy loading. What I mean is this: I want to display a grid that only shows, say, 20 records. I need an external scrollbar control that I can then show on the screen next to the grid. When...
1
1809
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 any other method to make it fast loading bala code:
7
5377
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 GridViewRow(0,0,DataControlRowType.DataRow, DataControlRowState.Normal); TableCell myCell = new TableCell(); TextBox myTextbox = new TextBox(); myTextbox.Text = "hello world"; myCell.Controls.Add(myTextbox);
8
2257
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 I can store them/preserve them so that when I post back I can use the values. I tried session and it works but some other ideas would be helpful. Appreciate your help, Stephen
8
3081
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 reflect the values they anticipate committing to see hypothetical totals of columns from a set of records. These records are displaying properly on my DataGrid but I'm not sure how to get Crystal Reports 10 to use as its datasource the dataset...
0
8739
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
8654
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,...
1
8983
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8941
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 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...
0
7832
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
6575
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
5910
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();...
1
3107
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
3
2037
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.