Show/Hide column in Gridview on my command

slimshady

Newcomer
Joined
Apr 18, 2006
Messages
8
Is it possible to show extra/new columns in a gridview after user has pressed Edit?

Lets say that when user goes to a page the GridView there shows two columns, one for first name and one for last name.
When user clicks Edit he then can edit first name, last name AND phone number.

If I set the TemplateField to "Visible = False" then there is no way to set Visible to True in the code behind since I cannot give the TemplateField an ID!?

And if I set the Textbox to "Visible = False" then it shows a column anyway (before I press Edit). Of course it is empty but still it shows an empty column which I don't want!

Anyone know how to do this??
 
slimshady said:
If I set the TemplateField to "Visible = False" then there is no way to set Visible to True in the code behind since I cannot give the TemplateField an ID!?

You don't need the ID; take the columnindex and change the column visibility instead . This is done in the PreRender event of the GridView.
 
Back
Top