469,625 Members | 1,655 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

DataGrid event handling problem

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!
--
MG
Jul 3 '06 #1
1 2916
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?
--
MG
"Mark Gilkes" wrote:
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!
--
MG
Jul 3 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by John Richardson | last post: by
2 posts views Thread by andla | last post: by
4 posts views Thread by The Alchemist | last post: by
4 posts views Thread by Suzanne | last post: by
1 post views Thread by mike | last post: by
5 posts views Thread by Steve | last post: by
2 posts views Thread by shuckjunkmail | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.