Connecting Tech Pros Worldwide Forums | Help | Site Map

How to access data from one datagrid to another in VB.Net

Coleen
Guest
 
Posts: n/a
#1: Nov 21 '05
Hi All :-)

I have a Fro?next loop where I have to calculate a grand total. I need to use that grand total to calculate percentages of data from the same For/Next loop. I can't get the grand total until the loop completes, so I have created another datagrid to dump the value of the grand total into. Now, I need to get the total from that datagrid and use it in my original For/Next Loop. Any suggestions on how to do this?

I have tried:

ld_pct_125_tot_gtr_fy_hh = CDbl(dt_grand_totals.Rows.Item(0).ToString)
where dt_grand_totals is my datagrid with the value I need to get to store in the variable ld_pct_125_tot_gtr_fy_hh

How can I get that value back from the other datagrid into my variable?

TIA



Coleen




Cor Ligthert
Guest
 
Posts: n/a
#2: Nov 21 '05

re: How to access data from one datagrid to another in VB.Net


Coleen,

Did you already look at this?

Datatable.compute
http://msdn.microsoft.com/library/de...mputetopic.asp

Maybe it helps easier?

Cor


Coleen
Guest
 
Posts: n/a
#3: Nov 21 '05

re: How to access data from one datagrid to another in VB.Net


Well, yes and no :-)

This works if you are connecting to an SQL database using a dataset. We connect to a DB2 database using an RPC to a COBOL program...very difficult to get the same results this way as you can connecting to a SQL DB! I don't use a dataset to be able to call the table column name. According to the example I would use:

Dataset1.Tables("TableName").Columns("ColumnName") .Expression = "ExpressionName"

If I could call the datagrid in the same fashion it might work for me. I tried:

dt_grand_totals.TableName("dtg_grand_totals").Colu mns("ld_act_125_gtr_fy_hh_avg_grnd_tot").Expressio n = "ld_pct_125_tot_gtr_fy_hh" where dt_grand_totals is the datatable, dtg_grand_totals is the datagrid name, ld_act_125_gtr_fy_hh_avg_grnd_tot is the column name and ld_pct_125_tot_gtr_fy_hh is the expression or variable that I want to store the value in.

This gives me the "Blue Squiggly" error "Public Overloads Property TableName() AS String' has no parameters and its return type cannot be indexed"

Any other suggestions?

Thanks :-)

Coleen


"Cor Ligthert" <notfirstname@planet.nl> wrote in message news:%23yueLxJgEHA.712@TK2MSFTNGP09.phx.gbl...[color=blue]
> Coleen,
>
> Did you already look at this?
>
> Datatable.compute
> http://msdn.microsoft.com/library/de...mputetopic.asp
>
> Maybe it helps easier?
>
> Cor
>
>[/color]
Closed Thread