Populate Session Variables from Datagrid for a specific cell

Discussion in 'ASP .Net' started by coleenholley, Feb 2, 2004.

  1. coleenholley

    coleenholley Guest

    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

    ---
    Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
    coleenholley, Feb 2, 2004
    #1
    1. Advertising

  2. 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
    <coleenholley> wrote in message
    news:%...
    > 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
    >
    > ---
    > Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest

    Community Website: http://www.dotnetjunkies.com/newsgroups/
    Alvin Bruney [MVP], Feb 3, 2004
    #2
    1. Advertising

  3. coleenholley

    coleenholley Guest

    re: Re: Populate Session Variables from Datagrid for a specific cell

    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

    ---
    Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
    coleenholley, Feb 3, 2004
    #3
  4. Re: Re: Populate Session Variables from Datagrid for a specific cell

    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
    <coleenholley> wrote in message
    news:...
    > 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
    >
    > ---
    > Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest

    Community Website: http://www.dotnetjunkies.com/newsgroups/
    Alvin Bruney [MVP], Feb 3, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cory D.
    Replies:
    1
    Views:
    676
    =?Utf-8?B?dGVuemVlbC4=?=
    Jul 28, 2004
  2. John Saunders
    Replies:
    0
    Views:
    404
    John Saunders
    Jul 27, 2004
  3. Eliyahu Goldin
    Replies:
    1
    Views:
    525
    =?Utf-8?B?dGVuemVlbC4=?=
    Jul 31, 2004
  4. Vivek Sharma

    Populate the textbox in cell of a datagrid

    Vivek Sharma, Nov 21, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    96
    Vivek Sharma
    Nov 21, 2005
  5. Enjoy Life
    Replies:
    2
    Views:
    272
    Roland Hall
    Feb 23, 2005
Loading...

Share This Page