Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Hide a column in asp:GridView

 
Thread Tools Search this Thread
Old 08-04-2006, 09:28 AM   #1
Default Hide a column in asp:GridView


Hi, I want to hide a column in the asp:GridView, say one of the column of
asp:BoundField. But it is not allowed to put <div> inside for setting it
display:none. What can I do? Thanks in millions.




ghostwolf
  Reply With Quote
Old 08-04-2006, 10:47 AM   #2
=?Utf-8?B?Y2xpY2tvbg==?=
 
Posts: n/a
Default RE: Hide a column in asp:GridView
To hide the third column for example ...

GridView.Columns[2].Visible = false;

"ghostwolf" wrote:

> Hi, I want to hide a column in the asp:GridView, say one of the column of
> asp:BoundField. But it is not allowed to put <div> inside for setting it
> display:none. What can I do? Thanks in millions.
>
>
>



=?Utf-8?B?Y2xpY2tvbg==?=
  Reply With Quote
Old 08-04-2006, 11:06 AM   #3
Mark Rae
 
Posts: n/a
Default Re: Hide a column in asp:GridView
"ghostwolf" <> wrote in message
news:...

> Hi, I want to hide a column in the asp:GridView, say one of the column of
> asp:BoundField. But it is not allowed to put <div> inside for setting it
> display:none. What can I do? Thanks in millions.


MyGridView.Columns[0].Visible = false;

HOWEVER, bear in mind that this isn't actually *hiding* the column per se -
it's physically *removing* the column from the HTML being sent down to the
client, which may not be what you really want...




Mark Rae
  Reply With Quote
Old 08-04-2006, 11:13 AM   #4
ghostwolf
 
Posts: n/a
Default Re: Hide a column in asp:GridView
thanks, actually I don't really want to invisible it. It is because I want
to put a value for each row but make it hide away. Just like what we did in
windows programming for adding a value for each row. If I make the column in
asp:GridView invisible, I cannot get the value from that column.

"Mark Rae" <> wrote in message
news:...
> "ghostwolf" <> wrote in message
> news:...
>
>> Hi, I want to hide a column in the asp:GridView, say one of the column of
>> asp:BoundField. But it is not allowed to put <div> inside for setting it
>> display:none. What can I do? Thanks in millions.

>
> MyGridView.Columns[0].Visible = false;
>
> HOWEVER, bear in mind that this isn't actually *hiding* the column per
> se - it's physically *removing* the column from the HTML being sent down
> to the client, which may not be what you really want...
>





ghostwolf
  Reply With Quote
Old 08-04-2006, 12:09 PM   #5
Mark Rae
 
Posts: n/a
Default Re: Hide a column in asp:GridView
"ghostwolf" <> wrote in message
news:O4v$...

> thanks, actually I don't really want to invisible it. It is because I want
> to put a value for each row but make it hide away. Just like what we did
> in windows programming for adding a value for each row. If I make the
> column in asp:GridView invisible, I cannot get the value from that column.


Ah... You've discovered the additional security feature that a GridView has
but a DataGrid didn't.

Basically, Microsoft took the view that using hidden columns to store data
was a potential security risk, so they removed hidden colums from ViewState
at databind time. However, it's easy enough to work round, but be aware of
the potential security risk involved in doing this...

MyGridView.DataSource = <datasource>;
MyGridView.Columns[0].Visible = true;
MyGridView.DataBind();
MyGridView.Columns[0].Visible = false;




Mark Rae
  Reply With Quote
Old 08-04-2006, 04:13 PM   #6
Winista
 
Posts: n/a
Default Re: Hide a column in asp:GridView
Check this out..

http://www.netomatix.com/development...ideColumn.aspx

"ghostwolf" <> wrote in message
news:...
> Hi, I want to hide a column in the asp:GridView, say one of the column of
> asp:BoundField. But it is not allowed to put <div> inside for setting it
> display:none. What can I do? Thanks in millions.
>





Winista
  Reply With Quote
Old 08-04-2006, 04:37 PM   #7
Mark Rae
 
Posts: n/a
Default Re: Hide a column in asp:GridView
"Winista" <> wrote in message
news:...

> Check this out..
>
> http://www.netomatix.com/development...ideColumn.aspx


Correct approach, terrible implementation!

Need to set display to either none or block to make this work properly.




Mark Rae
  Reply With Quote
Old 08-04-2006, 05:04 PM   #8
Winista
 
Posts: n/a
Default Re: Hide a column in asp:GridView
Thank you for pointing out the issue with the approach. It has been fixed on
the site as well as attached demo project.

"Mark Rae" <> wrote in message
news:...
> "Winista" <> wrote in message
> news:...
>
>> Check this out..
>>
>> http://www.netomatix.com/development...ideColumn.aspx

>
> Correct approach, terrible implementation!
>
> Need to set display to either none or block to make this work properly.
>





Winista
  Reply With Quote
Old 08-04-2006, 05:15 PM   #9
Mark Rae
 
Posts: n/a
Default Re: Hide a column in asp:GridView
"Winista" <> wrote in message
news:u$WE8%...

> Thank you for pointing out the issue with the approach. It has been fixed
> on the site as well as attached demo project.


Excellent. Check this out for cross-browser compatibility
http://www.quirksmode.org/css/display.html, but I think you're OK...




Mark Rae
  Reply With Quote
Old 08-07-2006, 12:19 AM   #10
ghostwolf
 
Posts: n/a
Default Re: Hide a column in asp:GridView
Thanks, it's great for me.

"Mark Rae" <> wrote in message
news:umI5vD%...
> "Winista" <> wrote in message
> news:u$WE8%...
>
>> Thank you for pointing out the issue with the approach. It has been fixed
>> on the site as well as attached demo project.

>
> Excellent. Check this out for cross-browser compatibility
> http://www.quirksmode.org/css/display.html, but I think you're OK...
>





ghostwolf
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How To Disable Or Hide EXPLORER TOOLBARS IN HTML PAGES Corona Media 1 10-11-2006 02:26 PM
Disable Hide Explorer Toolbars In Html Corona Software 0 10-08-2006 09:57 PM
DataGrid-Hyperlink column thiyag2001 Software 2 08-01-2006 12:50 PM
Invalid column name space Software 2 07-24-2006 07:41 PM
Counting In Binary Raymond A+ Certification 13 03-07-2004 07:28 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46