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

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
 
C

Christopher Reed

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

Pipo

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!
 
C

Christopher Reed

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.
 
P

Pipo

No, I am not doing that. It's already databound in design time(see OP)
It is bound through a ObjectDataSources.
 
C

Christopher Reed

Then, anytime you make a change to the GridView, you have to DataBind it
again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top