ItemDataBound event does not fire for selected row.

Discussion in 'ASP .Net' started by =?Utf-8?B?Z3JlZW5i?=, Apr 24, 2006.

  1. I'm using the ItemDataBound event of the DataGrid to highlight cells that are
    outside an acceptable range. Each row has a button column
    (CommandName='Select'), that is used to display addtional details below the
    grid.

    When the page first loads and when the 1st button column is clicked, the
    ItemDataBound event fires for each row in the datasource. But when the 2nd
    button column is clicked, the ItemDataBound event does not fire for the row
    that was clicked the first time. I know this may sound confusing so I've
    include my debug output below. There should always be 8 rows bound,
    4/10/2006 - 4/18/2006. All the rows are bound and appear in the grid as they
    should, it's just the ItemDataBound event doesn't fire. Anyone seen this one
    before?
    Thanks,
    Mark

    // initial page_load
    ItemIndex: 18
    DateHour: 04/10/2006
    ItemIndex: 19
    DateHour: 04/11/2006
    ItemIndex: 20
    DateHour: 04/12/2006
    ItemIndex: 21
    DateHour: 04/13/2006
    ItemIndex: 22
    DateHour: 04/14/2006
    ItemIndex: 23
    DateHour: 04/15/2006
    ItemIndex: 24
    DateHour: 04/16/2006
    ItemIndex: 25
    DateHour: 04/17/2006
    ItemIndex: 26
    DateHour: 04/18/2006

    // click on row for 4/11/2006
    ItemIndex: 18
    DateHour: 04/10/2006
    ItemIndex: 19
    DateHour: 04/11/2006
    ItemIndex: 20
    DateHour: 04/12/2006
    ItemIndex: 21
    DateHour: 04/13/2006
    ItemIndex: 22
    DateHour: 04/14/2006
    ItemIndex: 23
    DateHour: 04/15/2006
    ItemIndex: 24
    DateHour: 04/16/2006
    ItemIndex: 25
    DateHour: 04/17/2006
    ItemIndex: 26
    DateHour: 04/18/2006

    // click on row for 4/13/2006: now row 4/11/2006 with ItemIndex 19 is missing.
    ItemIndex: 18
    DateHour: 04/10/2006
    ItemIndex: 20
    DateHour: 04/12/2006
    ItemIndex: 21
    DateHour: 04/13/2006
    ItemIndex: 22
    DateHour: 04/14/2006
    ItemIndex: 23
    DateHour: 04/15/2006
    ItemIndex: 24
    DateHour: 04/16/2006
    ItemIndex: 25
    DateHour: 04/17/2006
    ItemIndex: 26
    DateHour: 04/18/2006
    =?Utf-8?B?Z3JlZW5i?=, Apr 24, 2006
    #1
    1. Advertising

  2. I figured it out. The event is firing, but after selection, the ItemType is
    no longer ItemType.Item or ItemType.AlternatingItem, it is now
    ItemType.SelectedItem. I added the check for ItemType.SelectedItem and am
    now processing the event correctly.

    "greenb" wrote:

    > I'm using the ItemDataBound event of the DataGrid to highlight cells that are
    > outside an acceptable range. Each row has a button column
    > (CommandName='Select'), that is used to display addtional details below the
    > grid.
    >
    > When the page first loads and when the 1st button column is clicked, the
    > ItemDataBound event fires for each row in the datasource. But when the 2nd
    > button column is clicked, the ItemDataBound event does not fire for the row
    > that was clicked the first time. I know this may sound confusing so I've
    > include my debug output below. There should always be 8 rows bound,
    > 4/10/2006 - 4/18/2006. All the rows are bound and appear in the grid as they
    > should, it's just the ItemDataBound event doesn't fire. Anyone seen this one
    > before?
    > Thanks,
    > Mark
    >
    > // initial page_load
    > ItemIndex: 18
    > DateHour: 04/10/2006
    > ItemIndex: 19
    > DateHour: 04/11/2006
    > ItemIndex: 20
    > DateHour: 04/12/2006
    > ItemIndex: 21
    > DateHour: 04/13/2006
    > ItemIndex: 22
    > DateHour: 04/14/2006
    > ItemIndex: 23
    > DateHour: 04/15/2006
    > ItemIndex: 24
    > DateHour: 04/16/2006
    > ItemIndex: 25
    > DateHour: 04/17/2006
    > ItemIndex: 26
    > DateHour: 04/18/2006
    >
    > // click on row for 4/11/2006
    > ItemIndex: 18
    > DateHour: 04/10/2006
    > ItemIndex: 19
    > DateHour: 04/11/2006
    > ItemIndex: 20
    > DateHour: 04/12/2006
    > ItemIndex: 21
    > DateHour: 04/13/2006
    > ItemIndex: 22
    > DateHour: 04/14/2006
    > ItemIndex: 23
    > DateHour: 04/15/2006
    > ItemIndex: 24
    > DateHour: 04/16/2006
    > ItemIndex: 25
    > DateHour: 04/17/2006
    > ItemIndex: 26
    > DateHour: 04/18/2006
    >
    > // click on row for 4/13/2006: now row 4/11/2006 with ItemIndex 19 is missing.
    > ItemIndex: 18
    > DateHour: 04/10/2006
    > ItemIndex: 20
    > DateHour: 04/12/2006
    > ItemIndex: 21
    > DateHour: 04/13/2006
    > ItemIndex: 22
    > DateHour: 04/14/2006
    > ItemIndex: 23
    > DateHour: 04/15/2006
    > ItemIndex: 24
    > DateHour: 04/16/2006
    > ItemIndex: 25
    > DateHour: 04/17/2006
    > ItemIndex: 26
    > DateHour: 04/18/2006
    >
    >
    =?Utf-8?B?Z3JlZW5i?=, Apr 24, 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. Peter Afonin
    Replies:
    2
    Views:
    455
    Peter Afonin
    Nov 19, 2003
  2. =?Utf-8?B?Q2hyaXMgRmluaw==?=

    Highlight datalist row on itemDataBound event

    =?Utf-8?B?Q2hyaXMgRmluaw==?=, Dec 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    5,092
    rcbalbo
    Aug 9, 2006
  3. derek
    Replies:
    0
    Views:
    565
    derek
    Feb 12, 2007
  4. Peter Afonin

    ItemDataBound doesn't fire when I use DeleteCommand

    Peter Afonin, Nov 19, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    104
    Peter Afonin
    Nov 19, 2003
  5. Peter Afonin

    ItemDataBound doesn't fire when I use DeleteCommand

    Peter Afonin, Nov 19, 2003, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    168
    Peter Afonin
    Nov 19, 2003
Loading...

Share This Page