Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DataGrid event handling problem

Reply
Thread Tools

DataGrid event handling problem

 
 
=?Utf-8?B?TWFyayBHaWxrZXM=?=
Guest
Posts: n/a
 
      07-03-2006
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWFyayBHaWxrZXM=?=
Guest
Posts: n/a
 
      07-03-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem handling DataGrid TemplateColumn Databinding Event Glenn Owens ASP .Net Datagrid Control 1 07-12-2004 02:07 PM
Web Custom Control - Datagrid Event Handling Problem The Alchemist ASP .Net 4 06-23-2004 03:07 PM
Web Custom Control - Datagrid Event Handling Problem The Alchemist ASP .Net Web Controls 4 06-23-2004 03:07 PM
Dynamic Datagrid UserControl Event Handling Colin Ramsay ASP .Net 0 04-17-2004 10:26 PM
Event Handling for Controls within a Datagrid Wayne ASP .Net 0 11-04-2003 10:46 PM



Advertisments