Home All Groups Group Topic Archive Search About

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

Author
16 Jan 2006 2:48 PM
ohyeahgo
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>

Author
16 Jan 2006 2:58 PM
ohyeahgo
is using data key names the only way ?
Author
16 Jan 2006 3:37 PM
ohyeahgo
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
Author
17 Jan 2006 12:45 PM
Wouter van Vugt
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
Author
31 Mar 2006 3:03 PM
Edo den Haring
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.

Show quoteHide quote
"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
>
>
Author
31 Mar 2006 5:38 PM
Teemu Keiski
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


Show quoteHide quote
"Edo den Haring" <EdodenHar***@discussions.microsoft.com> wrote in message
news:A77A9051-6B21-4E8A-BD3C-AD2AB66F1774@microsoft.com...
> 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
>>
>>
Author
3 Apr 2006 8:28 AM
Edo den Haring
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


Show quoteHide quote
"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" <EdodenHar***@discussions.microsoft.com> wrote in message
> news:A77A9051-6B21-4E8A-BD3C-AD2AB66F1774@microsoft.com...
> > 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
> >>
> >>
>
>
>