ProfK
ProfK

Reputation: 51063

Programmatically Make Bound Column Invisible

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?

Upvotes: 0

Views: 1771

Answers (4)

ProfK
ProfK

Reputation: 51063

Nick Craver

GridView_RowCreated

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

Upvotes: 0

Bob Dizzle
Bob Dizzle

Reputation: 1163

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

Upvotes: 0

Nick Craver
Nick Craver

Reputation: 630389

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;
}

Upvotes: 0

Brian
Brian

Reputation: 4930

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.

Upvotes: 2

Related Questions