You could try something like:
Dim dgcol As System.Web.UI.WebControls.DataGridColumn
For Each dgcol In myDG.Columns
If dgcol.HeaderText = "column to hide" Then dgcol.Visible = False
Next
in Page_Load after calling myDG.DataBind(). That will work with explicity
defined columns. I'm not sure if that works with auto-generated columns.
Good luck!
-Ryan
"Hanson" <he********@hotmail.com> wrote in message
news:uV**************@TK2MSFTNGP10.phx.gbl...
Hi Richard,
Thanks for your reply first. However the problem is I can not access the
autogenerated columns, and then I can not set the column's visible property.
"Richard" <ri*****@nospam.com> wrote in message
news:40***********************@newsreader.eweka.nl ...
Sorry Hanson, i misunderstood the question a bit,
anyway,
use a Visible = False
to make it invisible and not be showed then
"Hanson" <he********@hotmail.com> schreef in bericht
news:un*************@TK2MSFTNGP11.phx.gbl...
I have a datagrid control in an aspx page. The datagrid columns will be
dynamically generated according to the pre-page's search condition, I want
to hide some columns in the datagrid. is that anyway to do that?