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

  • Thread starter Thread starter Coleen
  • Start date Start date
C

Coleen

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
 
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").Columns("ld_act_125_gtr_fy_hh_avg_grnd_tot").Expression = "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
 
Back
Top