Hide a datagrid column

sj1187534

Well-known member
Joined
Jun 10, 2003
Messages
108
Location
Dallas, Houston, etc.etc.
Hi..Does anyone know how to hide a datagrid column that is created at runtime but not hard-coded???

I saw some articles that are talking about changing the visible property of the column. I guess that works only when the column is created within the code but not obtained from a dataset as it is in my case..

SJ
 
Hiding columns in a datagrid

This is in C#...

protected void Item_Bound(object sender, DataGridItemEventArgs e)
{
e.Items.Cells.[8].Visible = false;
}

...where cell "8" is the one you want to hide.

Note: Youll need to add OnItemDataBound="Item_Bound" to your HTML for the DataGrid, or insert it into whatever DataGrid argument youre currently using.
 
If you are using the datagridstyle to set it up you can just leave the clume out of the style definition or if you want it to be in the grid and readable by your code but not visible just set the width for that column to 0.
 
Hi....Thanks for the replies guys. I was able to accomplish what I wanted by just making the AutoGenerateColumns property "False" and inserting the Databound columns manually...That seems the best thing to do.

Thank u once again...

SJ
 
Back
Top