DataGrid event handling problem

Discussion in 'ASP .Net' started by =?Utf-8?B?TWFyayBHaWxrZXM=?=, Jul 3, 2006.

  1. 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
     
    =?Utf-8?B?TWFyayBHaWxrZXM=?=, Jul 3, 2006
    #1
    1. Advertising

  2. 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
     
    =?Utf-8?B?TWFyayBHaWxrZXM=?=, Jul 3, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wayne
    Replies:
    0
    Views:
    377
    Wayne
    Nov 4, 2003
  2. Colin Ramsay

    Dynamic Datagrid UserControl Event Handling

    Colin Ramsay, Apr 17, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    783
    Colin Ramsay
    Apr 17, 2004
  3. The Alchemist
    Replies:
    4
    Views:
    788
    Mircea Pleteriu
    Jun 23, 2004
  4. Glenn Owens

    Problem handling DataGrid TemplateColumn Databinding Event

    Glenn Owens, Jul 9, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    173
    Glenn Owens
    Jul 12, 2004
  5. The Alchemist

    Web Custom Control - Datagrid Event Handling Problem

    The Alchemist, Jun 7, 2004, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    192
    Mircea Pleteriu
    Jun 23, 2004
Loading...

Share This Page