DataGrid event handling problem

G

Guest

I have a DataGrid which I am adding to the page dynamically at the Init stage
of the page load. The DataGrid has AutoGenerateColumns turned off, has
BoundColumns and is bound to a DataView for its’ data source. I have also
added a TemplateColumn which is defined in a derived class and contains an
ImageButton. The derived TemplateColumn class contains an event handler for
DataBinding and in this handler I assign the ImageButton ID. The page that
contains my DataGrid contains two event handlers ItemCommand and SortCommand.
I have recently posted regarding a toggled sorting, which I have implemented
successfully. Although, since implementing the sorting I now have a very
strange behaviour occurring. When testing the toggled sorting I noticed that
the ItemCommand and SortCommand events stop firing if the columns are sorted
more than once, i.e. If you click the ImageButton (TemplateColumn) after
clicking the column headers more than once the page refreshes but neither the
ItemCommand or the SortCommand event fires. This is almost as if the event
delegate is lost for the TemplateColumn on the second round trip. Anyone
ideas would be gratefully received!
 
G

Guest

I'm sure the problem here lies with the fact that in the Init event handler
when I am building the DataGrid I declare a TemplateColumn and create an
ImageButton but during the SortCommand event handler I am re-binding the
datasource after the sort but I am not re-creating the TemplateColumn. Do I
need to remove the TemplateColumn and re-add it in the SortCommand event
handler? or is there an easier way to re-bind the TemplateColumn to the
datasource?
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top