Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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: You'll need to add OnItemDataBound="Item_Bound" to your HTML for the DataGrid, or insert it into whatever DataGrid argument you're currently using.

Posted
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.
Hamlet
Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...