asp.net vb.net gridview hide column, passing value hidden

I have a gridview with binded with a datatable. I have 4 fields in grid. Id, name, price and a button column. I need to know the value of the id when i press the button. If show the id column all works well. But i need hide the id column, and when hide this column an error occurs. How can pass a value in a hidden column in a gridview.
rflorencioAsked:
Who is Participating?
 
M3mph15Connect With a Mentor Commented:
Hi,

You can hide the Column by using a CssClass:

.HiddenColumn 'in style section of <head>
{
         display:none;
}


<Columns>
<asp:BoundField DataField="Action_Key"  HeaderText="Key" InsertVisible="False" >
               <HeaderStyle CssClass="HiddenColumn" />
               <ItemStyle CssClass="HiddenColumn" />
</asp:BoundFiled>
</Columns>

Just change the Asp:BoundField to whatever suits your needs....the important bit is the HeaderStyle and ItemStyle.

Then in you can access the value from code behind with no problem.

HTH
-M3mph15
0
 
nmarunCommented:
0
 
ki_kiConnect With a Mentor Commented:
you can use css file to hide the column too.
0
 
ki_kiCommented:
if you have the footer's show property set to true, you'll have to 'style' it as well.
Am I right M3mph15 ?
0
 
M3mph15Commented:
Ah yes you can use the same method to hide the footer aswell
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.