Removing columns from Gridview(2.0) databinding on templatefileds dont work?

  • Thread starter Thread starter Maarten
  • Start date Start date
M

Maarten

Hi,

I have a gridview (2.0), in the page load I remove a couple of columns from
the gridview which I dont need.
(All the columns are databound)
This works fine. But after a postback all the templatefields are not bind
anymore.
Only the boundfields are still bound.
Why? and what can I do about this?


Many thanks,

Page_Load:

If Not IsPostBack Then

'Loop to remove the extra columns we dont need:

end if
 
If you don't need them, remove from the design. This may actually help
resolve your main issue.
 
Hi Christopher,

I understand that, but that's no option.
I only know which one to remove at run-time, due to user selection.
And not at design-time!
 
Then, are you building your GridView in the Page_Load? If so, make sure the
call to the DataBind method is not inside the If (!IsPostBack) clause.
 
No, I am not doing that. It's already databound in design time(see OP)
It is bound through a ObjectDataSources.
 
Then, anytime you make a change to the GridView, you have to DataBind it
again.
 
Back
Top