DataGrid, SortCommand, TemplateColumn and rebinding

M

mark.gilkes

Hi,

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 (bi-directional) sorting, which I have implemented
successfully in the SortCommand event handler using simple view state
code. 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 for the
TemplateColumn on ever other round trip. This is due, I believe, to the
fact that when I sort in the SortCommand handler, I re-bind the
DataView and do not re-bind the TemplateColumn and therefore the
ImageButton is not re-created against the new DataGrid columns. I have
tried to remove the TemplateColumn in an attempt to re-add it before
binding the DataView only to get an error regarding collections
changing (using the DataGridColumnsCollection class to iterate through
the columns and removing the TemplateColumn). I have already posted a
similar question to the aspnet newsgroup but to no avail. Any help
would be gratefuly received.
(indecently could someone explain why this group isn't available
through the MSDN newsgroups site?)

Regards,

Mark.
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top