GridView "visible=False" data items not accessible? programattically

Discussion in 'ASP .Net Web Controls' started by ohyeahgo, Jan 16, 2006.

  1. ohyeahgo

    ohyeahgo Guest

    this might be an easy one.

    So "everything" is working and this GridView and it is NOT used to
    update data.

    I'm attempting to get to the "invisible" data columns in a gridview. I
    can easily access the shown data by

    doing something like this, it works for "visible" data but no hidden
    columns in my gridview.

    For Each Row In GridView1.Rows
    For J = 0 To 57
    testhold = Row.Cells.Item(J).Text.ToString
    Next
    Next


    Watch shows.

    J = 0, Testhold = '' <- this is whats wrong, there
    should be data here.
    J = 1, Testhold = '3.0'
    etc

    Basically any "visible" items data will show in the above loop. No
    "Visible = False" columns retain underneath data. (im trying to use
    keys without showing them to the user).

    Asp code ex... Supname always shows up empty (''). MonOtHrs shows
    the correct data.

    <asp:BoundField DataField="SupName" HeaderText="SupName"
    SortExpression="SupName" Visible="False" />

    <asp:BoundField DataField="MonOtHrs" HeaderText="OT"
    SortExpression="MonOtHrs"
    </asp:BoundField>
     
    ohyeahgo, Jan 16, 2006
    #1
    1. Advertising

  2. ohyeahgo

    ohyeahgo Guest

    is using data key names the only way ?
     
    ohyeahgo, Jan 16, 2006
    #2
    1. Advertising

  3. ohyeahgo

    ohyeahgo Guest

    this works...

    Dim key As DataKey = GridView1.DataKeys(0)


    For J = 0 To 57
    testhold = key.Item(2).ToString (key field
    num 2)
    testhold = Row.Cells.Item(J).Text.ToString

    Next
     
    ohyeahgo, Jan 16, 2006
    #3
  4. Hi,

    I think a invisible column isn't rendered on the clientside, and hence
    no roundtrip for that data. So basically, yes you have to use
    datakeynames and the datakeys collection to make this work.

    Grtz, Wouter van Vugt
     
    Wouter van Vugt, Jan 17, 2006
    #4
  5. Re: GridView "visible=False" data items not accessible? programatt

    If datakeys can't be used ?

    Is it possible to get to the datarow via
    Dim row DataRowView = CType(GridViewRow.DataItem (selectedrow))beneath t
    row("FieldName") ?

    I tried this but dataitem is Nothing ...

    In DataRowBound event is it possible to get to all the datafields in the
    dataset via the dataitem.

    "Wouter van Vugt" wrote:

    > Hi,
    >
    > I think a invisible column isn't rendered on the clientside, and hence
    > no roundtrip for that data. So basically, yes you have to use
    > datakeynames and the datakeys collection to make this work.
    >
    > Grtz, Wouter van Vugt
    >
    >
     
    Edo den Haring, Mar 31, 2006
    #5
  6. ohyeahgo

    Teemu Keiski Guest

    Re: GridView "visible=False" data items not accessible? programatt

    Hi,

    data source items & fields aren't stored with the GridView to ViewState
    (DataKeys being clear exception), so DataItem property is actually only
    accessible during the same sequence after the GridView has been bound (in
    practise in RowCreated and RowDataBound events raised after call to
    DataBind).

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke


    "Edo den Haring" <> wrote in message
    news:...
    > If datakeys can't be used ?
    >
    > Is it possible to get to the datarow via
    > Dim row DataRowView = CType(GridViewRow.DataItem (selectedrow))beneath t
    > row("FieldName") ?
    >
    > I tried this but dataitem is Nothing ...
    >
    > In DataRowBound event is it possible to get to all the datafields in the
    > dataset via the dataitem.
    >
    > "Wouter van Vugt" wrote:
    >
    >> Hi,
    >>
    >> I think a invisible column isn't rendered on the clientside, and hence
    >> no roundtrip for that data. So basically, yes you have to use
    >> datakeynames and the datakeys collection to make this work.
    >>
    >> Grtz, Wouter van Vugt
    >>
    >>
     
    Teemu Keiski, Mar 31, 2006
    #6
  7. Re: GridView "visible=False" data items not accessible? programatt

    Hi,

    Thanx ...

    I was afraid for this ... :)

    I tried to get the current record data into my own object after selection
    (using the select button) via the databoundrecord event.

    Using row.rowtype = datarow and row.rowstate = select I tried to isolate the
    record be selected. It did not work ... I seems that not each select click
    (using the select button) the datarowbound event is fired ...

    Is this correct ?

    Greetz,

    Edo


    "Teemu Keiski" wrote:

    > Hi,
    >
    > data source items & fields aren't stored with the GridView to ViewState
    > (DataKeys being clear exception), so DataItem property is actually only
    > accessible during the same sequence after the GridView has been bound (in
    > practise in RowCreated and RowDataBound events raised after call to
    > DataBind).
    >
    > --
    > Teemu Keiski
    > ASP.NET MVP, AspInsider
    > Finland, EU
    > http://blogs.aspadvice.com/joteke
    >
    >
    > "Edo den Haring" <> wrote in message
    > news:...
    > > If datakeys can't be used ?
    > >
    > > Is it possible to get to the datarow via
    > > Dim row DataRowView = CType(GridViewRow.DataItem (selectedrow))beneath t
    > > row("FieldName") ?
    > >
    > > I tried this but dataitem is Nothing ...
    > >
    > > In DataRowBound event is it possible to get to all the datafields in the
    > > dataset via the dataitem.
    > >
    > > "Wouter van Vugt" wrote:
    > >
    > >> Hi,
    > >>
    > >> I think a invisible column isn't rendered on the clientside, and hence
    > >> no roundtrip for that data. So basically, yes you have to use
    > >> datakeynames and the datakeys collection to make this work.
    > >>
    > >> Grtz, Wouter van Vugt
    > >>
    > >>

    >
    >
    >
     
    Edo den Haring, Apr 3, 2006
    #7
    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. John Saunders
    Replies:
    0
    Views:
    559
    John Saunders
    Jul 1, 2004
  2. =?Utf-8?B?Q0JyZXRhbmE=?=

    Programattically control WebPartManager outside of ASP Page?

    =?Utf-8?B?Q0JyZXRhbmE=?=, Nov 16, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    374
    =?Utf-8?B?Q0JyZXRhbmE=?=
    Nov 16, 2005
  3. Lars Uffmann
    Replies:
    3
    Views:
    274
    Erik Wikström
    Jan 18, 2008
  4. psb
    Replies:
    0
    Views:
    180
  5. J055
    Replies:
    4
    Views:
    866
    Steven Cheng[MSFT]
    Jun 14, 2006
Loading...

Share This Page