DataGrid, SortCommand, TemplateColumn and rebinding

Discussion in 'ASP .Net Datagrid Control' started by mark.gilkes@gmail.com, Jul 4, 2006.

  1. Guest

    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.
     
    , Jul 4, 2006
    #1
    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. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    DataGrid.DataBind() and SortCommand

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, May 20, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    552
    =?Utf-8?B?QWx0YWYgQWwtQW1pbiBOYWp3YW5p?=
    May 21, 2006
  2. =?Utf-8?B?TWFyayBHaWxrZXM=?=

    DataGrid, SortCommand and toggled sorting

    =?Utf-8?B?TWFyayBHaWxrZXM=?=, Jun 29, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    2,441
    =?Utf-8?B?TWFyayBHaWxrZXM=?=
    Jun 30, 2006
  3. Jules Dekker

    Dynamically created TemplateColumn does not raise SortCommand

    Jules Dekker, Feb 13, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    143
    Jules Dekker
    Feb 13, 2004
  4. John Walsch

    Autogenerated Datagrid columns rebinding problem on postback

    John Walsch, Jul 12, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    178
    John Walsch
    Jul 12, 2004
  5. biru
    Replies:
    2
    Views:
    234
Loading...

Share This Page