Populate Session Variables from Datagrid for a specific cell

C

coleenholley

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(

I am using VB.Net as the code behind, and populating the datagrid dynamically in a VB.Net Class Module - I am NOT connecting to an SQL database, but I do use the databind function

dtg_worksheet1.DataSource = lo_AZRM005A.get_dt_worksheet
dtg_worksheet1.DataBind(

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

Alvin Bruney [MVP]

Every row of data which is bound to the grid fires the itemdatabound event.
So in its handler, you can take the appropriate action. Consider
Session["row"] = e.item.cells[0].text will store the first colum of the row
being bou nd

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
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 Double
Session("wa_tot_gal") = tbl_worksheet1.Rows(16).Cells(3).Text()

I am using VB.Net as the code behind, and populating the datagrid
dynamically in a VB.Net Class Module - I am NOT connecting to an SQL
database, but I do use the databind function:
dtg_worksheet1.DataSource = lo_AZRM005A.get_dt_worksheet1
dtg_worksheet1.DataBind()

How can I do this programmatically with the datagrid? Any help is GREATLY appreciated! Coleen
Community Website: http://www.dotnetjunkies.com/newsgroups/
 
C

coleenholley

Thanks - that helps, but I need to get the value from a Specific row - the data returned will ALWAYS have 17 rows - it will return one row for each County in Nevada, and there are 17 Counties. I specifically need to get the value from row (county) 16 for a session variable. Using Session["row"] = e.item.cells[7].text will store the seventh colum of the which row? How do I tell it to specifically get row 16? I REALLY need to have the functionality of Row(16).Cell(7); it is imperitive to the application we are building...any suggestions on getting the exact row number? Thanks for your help. Coleen
 
A

Alvin Bruney [MVP]

off the top of my head, if i didn't have the dataset already cached, i'd
collect each row and stack it into an array list. Then push that array list
into session.

Remind me again why you need to have this in a session variable (i've lost
the original thread)? It would seem to me that if you cache the entire
dataset, or datatable, then you could easily retrieve the dataset and access
the value directly. Consider:

DataSet ds = Session["Data"] as DataSet;
if(ds != null && ds.Tables[0].Rows.Count > 16)
value = ds.Tables[0].Rows[16][7].ToString();

Ofcourse, it is more memory efficient to cache a datatable or to stack just
the rows in an arraylist.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Thanks - that helps, but I need to get the value from a Specific row - the
data returned will ALWAYS have 17 rows - it will return one row for each
County in Nevada, and there are 17 Counties. I specifically need to get the
value from row (county) 16 for a session variable. Using Session["row"] =
e.item.cells[7].text will store the seventh colum of the which row? How do
I tell it to specifically get row 16? I REALLY need to have the
functionality of Row(16).Cell(7); it is imperitive to the application we are
building...any suggestions on getting the exact row number? Thanks for your
help. ColeenCommunity Website: http://www.dotnetjunkies.com/newsgroups/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top