HighTechTalks DotNet Forums  

Making an entire column visible/not visible.

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss Making an entire column visible/not visible. in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Mufasa
 
Posts: n/a

Default Making an entire column visible/not visible. - 11-13-2007 , 08:32 AM






How can I programatically change whether a column is visible/not visible in
a DataGrid?

TIA - Jeff.



Reply With Quote
  #2  
Old   
Eliyahu Goldin
 
Posts: n/a

Default Re: Making an entire column visible/not visible. - 11-13-2007 , 08:59 AM






You need to do it for every item in ItemDataBound event.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"Mufasa" <jb (AT) nowhere (DOT) com> wrote

Quote:
How can I programatically change whether a column is visible/not visible
in a DataGrid?

TIA - Jeff.





Reply With Quote
  #3  
Old   
Mufasa
 
Posts: n/a

Default Re: Making an entire column visible/not visible. - 11-13-2007 , 10:34 AM



Will that make the item in the row visible/invisible or the entire column
invisible? I want to be able to have a complete column (header included)
appear/not appear.

"Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN (AT) mMvVpPsS (DOT) org> wrote in
message news:%23cm4qXgJIHA.4584 (AT) TK2MSFTNGP03 (DOT) phx.gbl...
Quote:
You need to do it for every item in ItemDataBound event.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"Mufasa" <jb (AT) nowhere (DOT) com> wrote in message
news:eetoXIgJIHA.4272 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
How can I programatically change whether a column is visible/not visible
in a DataGrid?

TIA - Jeff.







Reply With Quote
  #4  
Old   
Eliyahu Goldin
 
Posts: n/a

Default Re: Making an entire column visible/not visible. - 11-13-2007 , 10:54 AM



ItemDataBound event fires for every item (row) including header and footer.
You will need to locate in the item the cell that belongs to the required
column and hide it like

e.Item.Cells[i].Visible = false;

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"Mufasa" <jb (AT) nowhere (DOT) com> wrote

Quote:
Will that make the item in the row visible/invisible or the entire column
invisible? I want to be able to have a complete column (header included)
appear/not appear.

"Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN (AT) mMvVpPsS (DOT) org> wrote in
message news:%23cm4qXgJIHA.4584 (AT) TK2MSFTNGP03 (DOT) phx.gbl...
You need to do it for every item in ItemDataBound event.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"Mufasa" <jb (AT) nowhere (DOT) com> wrote in message
news:eetoXIgJIHA.4272 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
How can I programatically change whether a column is visible/not visible
in a DataGrid?

TIA - Jeff.









Reply With Quote
  #5  
Old   
Riki
 
Posts: n/a

Default Re: Making an entire column visible/not visible. - 11-17-2007 , 12:43 PM



Quote:
"Mufasa" <jb (AT) nowhere (DOT) com> wrote in message
news:eetoXIgJIHA.4272 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
How can I programatically change whether a column is visible/not
visible in a DataGrid?
TIA - Jeff.
Eliyahu Goldin wrote:
Quote:
You need to do it for every item in ItemDataBound event.
That is not true.

You can set
DataGrid1.Columns(i).Visible=True

--

Riki




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.