467,895 Members | 1,407 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,895 developers. It's quick & easy.

Populating a datagrid dynamically, creating Session Variabbles

Hi all :-) I have a couple of web pages created using ASP.Net and VB code-behind. We use a connection call through an RPC to COBOL, NOT an SQL connection, so my connection to get the data is done in a Class Module (VB), which populates the datagrid. The datagrid is bound in the code-behind the ASPX page, as such

dtg_worksheet1.DataSource = lo_AZRM005A.get_dt_worksheet
dtg_worksheet1.DataBind(

The code to populate my datagrid from the class module (inpart) is
'Create the column headers
dt_worksheet1.Columns.Add(New DataColumn("County")
dt_worksheet1.Columns.Add(New DataColumn("Gasoline Gallons")
dt_worksheet1.Columns.Add(New DataColumn("Gasohol Gallons")
dt_worksheet1.Columns.Add(New DataColumn("Total Gallons")
'Build the DataTable with the Data

For i = 0 To li_rpd_array_row_len - 1 Step i +
Tr
' row number and withdrawal type
ls_temp = ao_buffer.ExtractString(CType(li_start_arr, Short), CType(li_arr_str_len, Short)
dr_gallons = dt_worksheet1.NewRow(
ls_temp_arr = ls_temp.Substring(li_county_name, li_county_name_len).Trim(
ls_county = ls_temp_arr.ToString().Tri
dr_gallons(0) = ls_count
ls_temp_arr = ls_temp.Substring(li_tot_gas_glln, li_tot_gas_glln_len).Trim(
ls_tot_gas = ls_temp_arr.ToString().Trim(
dr_gallons(1) = CInt(ls_tot_gas
ls_temp_arr = ls_temp.Substring(li_tot_gasohol_glln, li_tot_gasohol_glln_len).Trim(
ls_tot_gasohol = ls_temp_arr.ToString().Tri
dr_gallons(2) = CInt(ls_tot_gasohol
ls_tot_gallons = CDbl(ls_tot_gasohol) + CDbl(ls_tot_gas
dr_gallons(3) = CDbl(ls_tot_gallons

I need to know how to get a specific row/cell of data to post as a session variable - like I would with an ASP.Net table:

Dim ld_sum_tot_cty_tax As Doubl
Session("wa_tot_gal") = tbl_worksheet1.Rows(16).Cells(3).Text(

How can I do this programmatically with the datagrid? Any help is GREATLY appreciated! Coleen

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 20 '05 #1
  • viewed: 5085
Share:
7 Replies
Cor
Hi Coleen,

The session variable in aspx acts the same as in classic asp pages.
I have not seen any differences till now. But another posibility is the
"viewstate", have a look for that on MSDN I think that is better for the
solution you are looking for.

Maybe for you intresting is that tomorrow is this chat that I wrote beneath

I hope this helps?

Cor
---------------------------------------------------------------------------
Do you have questions about how to create great ASP.NET applications with
Visual Basic .NET? Join members of the Visual Basic and Web Forms teams for
a discussion about getting the most out of your Web applications. Get
answers from the experts to your questions about Visual Basic and ASP.NET.

Date:
February 3, 2004

Time:
1:00 - 2:00 P.M. Pacific time
4:00 - 5:00 P.M. Eastern time
21:00 - 22:00 BST/BST
(For a list of local time zones relative to GMT, please see
http://msdn.microsoft.com/chats/timezones.asp.)

Outlook Reminder:
http://msdn.microsoft.com/chats/outl...s/VS_Feb03.vcs

Location:
http://msdn.microsoft.com/chats (then click the name of the chat to enter
the chat room)

For more information about Visual Basic .NET, see
http://msdn.microsoft.com/vbasic/
To see a list of upcoming chats or set a reminder for this chat, see
http://msdn.microsoft.com/chats.
For archives of previous chats, see
http://msdn.microsoft.com/chats/recent.asp.

Thanks!
Jason Cooke
VB.NET Team
========
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
(c) 2004 Microsoft Corporation. All rights reserved.
-------------------------------------------------

Nov 20 '05 #2
Honestly, I'm not looking for how to get the Session variable, I know how to do that, I'm trying to get a specific row/cell of data from the dynamically populated datagrid (to use as my session variable), and so far, not having much luck...thanks for your help :-)

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 20 '05 #3
Cor
Hi Coleen,

The problem is I do not see that tbl_workstheet1 when it is just a typo and
had to be dt_worksheet1 than I think it can be something as
Session("wa_tot_gal") = dt_worksheet1.Rows(16)(3).tostring
or complete
dt_workstheet1.Rows(16).item(3).tostring

I am curious if it was that?

Cor
Nov 20 '05 #4
No, I used the example of getting the specific row/column form an ASP table...I need to know how to get a specific row/column from a dynamically populated datagrid...

I have been trying everything I can think of to get the specific row(18).cell(7) from my datagrid. This works perfectly in an ASP table but NOT in a datagrid! I checked the Help files and can return a specific column, but I can't get to the specific ROW - I keep getting an error that the row is out of bounds. Or, I get an error (blue squigleys) that Row is not a part of Items or of Columns properties...ARGH! I just want a specific Row(18).Cell(7) from my datagrid - please how do I get this info from a datagrid? Thanks for your help :-) Coleen

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 20 '05 #5
Cor
Hi Colleen,

But why not just from your underlaying datatable, you have it.
(I did a while nothing with a aspx datagrid and that should I investigate).

Cor
Nov 20 '05 #6
I can't get the SPECIFIC row - it is imperitive that I get the value from specifically row 16, cell 7. This is simple in the ASPX table, but I can not get it from the datagrid. I can return a specific column, but Ican't seem to get it to give me the value for the exact row I need...any suggestions?

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

Can you try this?

When clicked
Dim a As String = grd.Items(e.Item.ItemIndex).Cells(3).Text

or as you ask

Dim a as string = grd.Items(15).Cells(6).Text

I hope this helps?

Cor
<
I can't get the SPECIFIC row - it is imperitive that I get the value from specifically row 16, cell 7. This is simple in the ASPX table, but I can
not get it from the datagrid. I can return a specific column, but Ican't
seem to get it to give me the value for the exact row I need...any
suggestions?

Nov 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jim Heavey | last post: by
2 posts views Thread by ddaniel | last post: by
2 posts views Thread by John Ninan | last post: by
2 posts views Thread by charliewest | last post: by
reply views Thread by John Hopper | last post: by
9 posts views Thread by netasp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.