Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 30, 2012 08:01 PM by lesponce
Apr 30, 2012 05:31 PM|LINK
I got a gridview with a BoundField set to Visible=False. The problem is that I need the value in the code behind.
How can I have that field invisible to the user, but visible in the code behind?
Apr 30, 2012 05:55 PM|LINK
I think if you set the visibility of the column to false, it won't render the column, however you could use styling to hide the column itself using CSS.
Take a look at this article;
Apr 30, 2012 05:59 PM|LINK
In select command select that field also and add it to DataKeynames list and retrieve it whenever needed
If it is in RowdataBoundEvent get it as
string myKey = GridView1.DataKeys[e.RowIndex].Values[index of DatakeyNames].ToString();
Apr 30, 2012 06:25 PM|LINK
It's in a RowCommand event because of a Select Button.
Apr 30, 2012 06:30 PM|LINK
OnRowDataBound should still work even if its a rowcommand.
Apr 30, 2012 08:01 PM|LINK
I ended up using this one.... Thx for your help.
// Bind GridView to Data Source
GVAddress.DataSource = dtAddress; GVAddress.DataBind();
//Set visible to false for AddressId column after binding
(Step 4) from your link