tags:

views:

901

answers:

4

I'm trying to make a data bound column invisible after data binding, because it won't exist before data binding. However, the DataGrid.Columns collection indicates a count of 0, making it seem as if the automatically generated columns don't belong to the collection.

How can I make a column that is automatically generated during binding invisible?

+2  A: 

You have to add code to the line item rendering code and set the visibility of that column to false. Even though its bound, the event will be fired for each record and you can manipulate the output.

Brian
A: 

The only way to do this I know of since it's created on the fly is to hide the cell, here's an example you can adapt:

protected void GridView_RowCreated(object sender, GridViewRowEventArgs e)
{
  e.Row.Cells[1].Visible = false;
}
Nick Craver
A: 

If I understand your scenerio correctly you'll probably want to set it's visible property during the databound event

Bob Dizzle
A: 

Nick Craver

GridView_RowCreated

Nick, I'm not using a GridView. It's ItemCreated ;-)

ProfK
Ah right you are, it's been forever since I saw "grid" and thought DataGrid.
Nick Craver