ItemDataBound Event - How to access the previous record when this event is raised in DataGrid?

Discussion in 'ASP .Net Datagrid Control' started by NH, Dec 14, 2004.

  1. NH

    NH Guest

    ItemDataBound Event - How to access the previous record when this event is
    raised in DataGrid?



    During "ItemDataBound Event", I would like change the background color of a
    column in previous row depending on some condition in the column in current
    row.



    Thanks in Advance,


    NH
    NH, Dec 14, 2004
    #1
    1. Advertising

  2. ItemDataBound is not a good place for that. Use PreRender. Over there you
    can loop through the rows freely, they are all before you.

    Eliyahu

    "NH" <> wrote in message
    news:%230dJ$...
    > ItemDataBound Event - How to access the previous record when this event is
    > raised in DataGrid?
    >
    >
    >
    > During "ItemDataBound Event", I would like change the background color of

    a
    > column in previous row depending on some condition in the column in

    current
    > row.
    >
    >
    >
    > Thanks in Advance,
    >
    >
    > NH
    >
    >
    Eliyahu Goldin, Dec 15, 2004
    #2
    1. Advertising

  3. In the ItemDataBound Event you could reference the prvious cell using the
    itemindex property of the current item, such as:

    private void dgReport_ItemDataBound(object sender,
    System.Web.UI.WebControls.DataGridItemEventArgs e)

    {

    e.Item.ItemIndex //current item index

    e.Item.ItemIndex-1 //previous item index

    }



    "NH" <> wrote in message
    news:%230dJ$...
    > ItemDataBound Event - How to access the previous record when this event is
    > raised in DataGrid?
    >
    >
    >
    > During "ItemDataBound Event", I would like change the background color of
    > a
    > column in previous row depending on some condition in the column in
    > current
    > row.
    >
    >
    >
    > Thanks in Advance,
    >
    >
    > NH
    >
    >
    Andrew L. Van Slaars, Dec 17, 2004
    #3
    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. Dave

    ItemDataBound event of DataGrid

    Dave, Oct 7, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,929
    Scott Allen
    Oct 7, 2004
  2. MattB
    Replies:
    4
    Views:
    21,213
  3. adiel
    Replies:
    1
    Views:
    296
    adiel
    Jul 17, 2003
  4. Frederico Almeida

    DataGrid onresize event not raised

    Frederico Almeida, Mar 4, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    121
    Frederico Almeida
    Mar 4, 2006
  5. Maximus
    Replies:
    2
    Views:
    181
    Bob Barrows [MVP]
    Apr 12, 2007
Loading...

Share This Page