Groups | Blog | Home
all groups > asp.net datagrid control > november 2007 >

asp.net datagrid control : Making an entire column visible/not visible.


Mufasa
11/13/2007 9:32:58 AM
How can I programatically change whether a column is visible/not visible in
a DataGrid?

TIA - Jeff.

Mufasa
11/13/2007 11:34:51 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@mMvVpPsS.org> wrote in
message news:%23cm4qXgJIHA.4584@TK2MSFTNGP03.phx.gbl...
[quoted text, click to view]

Eliyahu Goldin
11/13/2007 4:59:46 PM
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


[quoted text, click to view]

Eliyahu Goldin
11/13/2007 6:54:48 PM
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


[quoted text, click to view]

Riki
11/17/2007 7:43:53 PM
[quoted text, click to view]

That is not true.

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

--

Riki

AddThis Social Bookmark Button