Damnit, Jim. Where is my data?!

S

Scott M

I am binding an array of objects to a datagrid and storing an internal ID in
a hidden column in my datagrid for updating the database. All is well while
I'm testing it out. But, as soon as I turn the column's visible property to
"False" the data disappears!! I tried it with a template column AND a
databound column!! What gives? How do I retrieve the value?

Thanks
Scott
 
S

Steven Cheng[MSFT]

Hi Scott,

Welcome to ASP.NET newsgroup.
Regarding on the problem you met when try retrieving value from invisble
Column in DataGrid, it is caused by the DataGrid's processing on invisible
column. DataGrid won't render the content for Columns that are set to
invisible.
So for your secnario, if we need to store additional data in each row (to
be used latter in postback event), we can consider either of the following
means:

1. Still use TemplateColumn, but don't set the whole column to invisible,
but put a inner sub control (which hold the additional value) and set this
inner control to invisible. (I'll recommend the HtmlInputHIdden html
control) Then, in the postback event, we can use DataGridItem(or sub
cell)'s find control to retrieve the control and its held data.

2. all the Control instance in asp.net has the Attributes collection which
will be persisted in the ViewState by default. So we can also use this
collection(e.g, use the DataGrieItem's Attirbutes collection to store the
value we want). The storeing code can be put in the DataGrid's
ItemDataBound event.

Just some of my suggestions. Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)









--------------------
| From: "Scott M" <[email protected]>
| Subject: Damnit, Jim. Where is my data?!
| Date: Thu, 1 Sep 2005 02:32:07 -0500
| Lines: 10
| MIME-Version: 1.0
| Content-Type: text/plain;
| format=flowed;
| charset="iso-8859-1";
| reply-type=original
| Content-Transfer-Encoding: 7bit
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| NNTP-Posting-Host: adsl-068-209-157-050.sip.lft.bellsouth.net
68.209.157.50
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridcontrol:5441
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
|
| I am binding an array of objects to a datagrid and storing an internal ID
in
| a hidden column in my datagrid for updating the database. All is well
while
| I'm testing it out. But, as soon as I turn the column's visible property
to
| "False" the data disappears!! I tried it with a template column AND a
| databound column!! What gives? How do I retrieve the value?
|
| Thanks
| Scott
|
|
|
 
E

Eliyahu Goldin

Scott,

Setting the column's Visible property to false results in not sending the
column to the client in the first place. That's why you don't get any value
on postback. You should hide the column with css rule display:none.

Eliyahu
 
S

Steven Cheng[MSFT]

You're welcome Scott,

If anything else we can help, please feel free to post here.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Scott M" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: Re: Damnit, Jim. Where is my data?!
| Date: Fri, 16 Sep 2005 14:00:52 -0500
| Lines: 86
| MIME-Version: 1.0
| Content-Type: text/plain;
| format=flowed;
| charset="iso-8859-1";
| reply-type=original
| Content-Transfer-Encoding: 7bit
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| NNTP-Posting-Host: adsl-068-209-157-050.sip.lft.bellsouth.net
68.209.157.50
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridcontrol:5553
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
|
| Thanks much, Steven. I'll give this a try and let you know how it goes.
|
| | > Hi Scott,
| >
| > Welcome to ASP.NET newsgroup.
| > Regarding on the problem you met when try retrieving value from invisble
| > Column in DataGrid, it is caused by the DataGrid's processing on
invisible
| > column. DataGrid won't render the content for Columns that are set to
| > invisible.
| > So for your secnario, if we need to store additional data in each row
(to
| > be used latter in postback event), we can consider either of the
following
| > means:
| >
| > 1. Still use TemplateColumn, but don't set the whole column to
invisible,
| > but put a inner sub control (which hold the additional value) and set
this
| > inner control to invisible. (I'll recommend the HtmlInputHIdden html
| > control) Then, in the postback event, we can use DataGridItem(or sub
| > cell)'s find control to retrieve the control and its held data.
| >
| > 2. all the Control instance in asp.net has the Attributes collection
which
| > will be persisted in the ViewState by default. So we can also use this
| > collection(e.g, use the DataGrieItem's Attirbutes collection to store
the
| > value we want). The storeing code can be put in the DataGrid's
| > ItemDataBound event.
| >
| > Just some of my suggestions. Hope helps. Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| >
| >
| >
| >
| >
| >
| > --------------------
| > | From: "Scott M" <[email protected]>
| > | Subject: Damnit, Jim. Where is my data?!
| > | Date: Thu, 1 Sep 2005 02:32:07 -0500
| > | Lines: 10
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > | format=flowed;
| > | charset="iso-8859-1";
| > | reply-type=original
| > | Content-Transfer-Encoding: 7bit
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | Message-ID: <[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | NNTP-Posting-Host: adsl-068-209-157-050.sip.lft.bellsouth.net
| > 68.209.157.50
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.datagridcontrol:5441
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > |
| > | I am binding an array of objects to a datagrid and storing an
internal
| > ID
| > in
| > | a hidden column in my datagrid for updating the database. All is well
| > while
| > | I'm testing it out. But, as soon as I turn the column's visible
| > property
| > to
| > | "False" the data disappears!! I tried it with a template column AND a
| > | databound column!! What gives? How do I retrieve the value?
| > |
| > | Thanks
| > | Scott
| > |
| > |
| > |
| >
|
|
 
S

Steven Cheng[MSFT]

My pleasure:)

Have a nice day!

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "Scott M" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: Damnit, Jim. Where is my data?!
| Date: Thu, 22 Sep 2005 00:08:40 -0500
| Lines: 146
| MIME-Version: 1.0
| Content-Type: text/plain;
| format=flowed;
| charset="iso-8859-1";
| reply-type=original
| Content-Transfer-Encoding: 7bit
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| NNTP-Posting-Host: adsl-068-209-157-050.sip.lft.bellsouth.net
68.209.157.50
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridcontrol:5603
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
|
| You rock. The hidden input field is what I needed :)
|
| Thanks much!
|
| | > You're welcome Scott,
| >
| > If anything else we can help, please feel free to post here.
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| > --------------------
| > | From: "Scott M" <[email protected]>
| > | References: <[email protected]>
| > <[email protected]>
| > | Subject: Re: Damnit, Jim. Where is my data?!
| > | Date: Fri, 16 Sep 2005 14:00:52 -0500
| > | Lines: 86
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > | format=flowed;
| > | charset="iso-8859-1";
| > | reply-type=original
| > | Content-Transfer-Encoding: 7bit
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | Message-ID: <[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | NNTP-Posting-Host: adsl-068-209-157-050.sip.lft.bellsouth.net
| > 68.209.157.50
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.datagridcontrol:5553
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > |
| > | Thanks much, Steven. I'll give this a try and let you know how it
goes.
| > |
| > | | > | > Hi Scott,
| > | >
| > | > Welcome to ASP.NET newsgroup.
| > | > Regarding on the problem you met when try retrieving value from
| > invisble
| > | > Column in DataGrid, it is caused by the DataGrid's processing on
| > invisible
| > | > column. DataGrid won't render the content for Columns that are set
to
| > | > invisible.
| > | > So for your secnario, if we need to store additional data in each
row
| > (to
| > | > be used latter in postback event), we can consider either of the
| > following
| > | > means:
| > | >
| > | > 1. Still use TemplateColumn, but don't set the whole column to
| > invisible,
| > | > but put a inner sub control (which hold the additional value) and
set
| > this
| > | > inner control to invisible. (I'll recommend the HtmlInputHIdden html
| > | > control) Then, in the postback event, we can use DataGridItem(or
sub
| > | > cell)'s find control to retrieve the control and its held data.
| > | >
| > | > 2. all the Control instance in asp.net has the Attributes collection
| > which
| > | > will be persisted in the ViewState by default. So we can also use
this
| > | > collection(e.g, use the DataGrieItem's Attirbutes collection to
store
| > the
| > | > value we want). The storeing code can be put in the DataGrid's
| > | > ItemDataBound event.
| > | >
| > | > Just some of my suggestions. Hope helps. Thanks,
| > | >
| > | > Steven Cheng
| > | > Microsoft Online Support
| > | >
| > | > Get Secure! www.microsoft.com/security
| > | > (This posting is provided "AS IS", with no warranties, and confers
no
| > | > rights.)
| > | >
| > | >
| > | >
| > | >
| > | >
| > | >
| > | >
| > | >
| > | >
| > | > --------------------
| > | > | From: "Scott M" <[email protected]>
| > | > | Subject: Damnit, Jim. Where is my data?!
| > | > | Date: Thu, 1 Sep 2005 02:32:07 -0500
| > | > | Lines: 10
| > | > | MIME-Version: 1.0
| > | > | Content-Type: text/plain;
| > | > | format=flowed;
| > | > | charset="iso-8859-1";
| > | > | reply-type=original
| > | > | Content-Transfer-Encoding: 7bit
| > | > | X-Priority: 3
| > | > | X-MSMail-Priority: Normal
| > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | > | Message-ID: <[email protected]>
| > | > | Newsgroups:
microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | > | NNTP-Posting-Host: adsl-068-209-157-050.sip.lft.bellsouth.net
| > | > 68.209.157.50
| > | > | Path:
| > TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| > | > | Xref: TK2MSFTNGXA01.phx.gbl
| > | > microsoft.public.dotnet.framework.aspnet.datagridcontrol:5441
| > | > | X-Tomcat-NG:
| > microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | > |
| > | > | I am binding an array of objects to a datagrid and storing an
| > internal
| > | > ID
| > | > in
| > | > | a hidden column in my datagrid for updating the database. All is
| > well
| > | > while
| > | > | I'm testing it out. But, as soon as I turn the column's visible
| > | > property
| > | > to
| > | > | "False" the data disappears!! I tried it with a template column
AND
| > a
| > | > | databound column!! What gives? How do I retrieve the value?
| > | > |
| > | > | Thanks
| > | > | Scott
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| >
|
|
 
S

Scott M

The hidden field worked awesome!! Thanks!

Steven Cheng said:
You're welcome Scott,

If anything else we can help, please feel free to post here.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Scott M" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: Re: Damnit, Jim. Where is my data?!
| Date: Fri, 16 Sep 2005 14:00:52 -0500
| Lines: 86
| MIME-Version: 1.0
| Content-Type: text/plain;
| format=flowed;
| charset="iso-8859-1";
| reply-type=original
| Content-Transfer-Encoding: 7bit
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| NNTP-Posting-Host: adsl-068-209-157-050.sip.lft.bellsouth.net
68.209.157.50
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridcontrol:5553
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
|
| Thanks much, Steven. I'll give this a try and let you know how it goes.
|
| | > Hi Scott,
| >
| > Welcome to ASP.NET newsgroup.
| > Regarding on the problem you met when try retrieving value from
invisble
| > Column in DataGrid, it is caused by the DataGrid's processing on
invisible
| > column. DataGrid won't render the content for Columns that are set to
| > invisible.
| > So for your secnario, if we need to store additional data in each row
(to
| > be used latter in postback event), we can consider either of the
following
| > means:
| >
| > 1. Still use TemplateColumn, but don't set the whole column to
invisible,
| > but put a inner sub control (which hold the additional value) and set
this
| > inner control to invisible. (I'll recommend the HtmlInputHIdden html
| > control) Then, in the postback event, we can use DataGridItem(or sub
| > cell)'s find control to retrieve the control and its held data.
| >
| > 2. all the Control instance in asp.net has the Attributes collection
which
| > will be persisted in the ViewState by default. So we can also use this
| > collection(e.g, use the DataGrieItem's Attirbutes collection to store
the
| > value we want). The storeing code can be put in the DataGrid's
| > ItemDataBound event.
| >
| > Just some of my suggestions. Hope helps. Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| >
| >
| >
| >
| >
| >
| > --------------------
| > | From: "Scott M" <[email protected]>
| > | Subject: Damnit, Jim. Where is my data?!
| > | Date: Thu, 1 Sep 2005 02:32:07 -0500
| > | Lines: 10
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > | format=flowed;
| > | charset="iso-8859-1";
| > | reply-type=original
| > | Content-Transfer-Encoding: 7bit
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | Message-ID: <[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | NNTP-Posting-Host: adsl-068-209-157-050.sip.lft.bellsouth.net
| > 68.209.157.50
| > | Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.datagridcontrol:5441
| > | X-Tomcat-NG:
microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > |
| > | I am binding an array of objects to a datagrid and storing an
internal
| > ID
| > in
| > | a hidden column in my datagrid for updating the database. All is
well
| > while
| > | I'm testing it out. But, as soon as I turn the column's visible
| > property
| > to
| > | "False" the data disappears!! I tried it with a template column AND
a
| > | databound column!! What gives? How do I retrieve the value?
| > |
| > | Thanks
| > | Scott
| > |
| > |
| > |
| >
|
|
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top