ItemDataBound of repeater... Before or after render?

Discussion in 'ASP .Net' started by Darren Clark, Aug 31, 2004.

  1. Darren Clark

    Darren Clark Guest

    I am trying to work out how to change some values of data during
    itemdatabound.

    MSDN states that the ItemDataBound is called BEFORE the render... so any
    changes do the data SHOULD work..

    however ihave the following example... and it doesnt work at all... the
    text CHANGE_Value does not come up at any time...


    public void rptList_ItemDataBound(Object Sender, RepeaterItemEventArgs e)

    {

    DataRowView drv = (DataRowView) e.Item.DataItem;

    if (drv == null)

    return;

    drv["body"] = "CHANGE_Value";// + row["body"].ToString();

    }
     
    Darren Clark, Aug 31, 2004
    #1
    1. Advertising

  2. Darren Clark

    Scott Allen Guest

    Hi Darren:

    This event happens before render but AFTER data binding for the item.
    If you change the row in the underlying data source it won't be found
    since the value was already bound to the control. You'll want to
    change a value in e.Item.Controls collection at this point to a
    different result to appear on the screen.

    HTH,

    --
    Scott
    http://www.OdeToCode.com

    On Tue, 31 Aug 2004 10:57:15 +1000, "Darren Clark"
    <> wrote:

    >I am trying to work out how to change some values of data during
    >itemdatabound.
    >
    >MSDN states that the ItemDataBound is called BEFORE the render... so any
    >changes do the data SHOULD work..
    >
    >however ihave the following example... and it doesnt work at all... the
    >text CHANGE_Value does not come up at any time...
    >
    >
    >public void rptList_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
    >
    >{
    >
    >DataRowView drv = (DataRowView) e.Item.DataItem;
    >
    >if (drv == null)
    >
    >return;
    >
    >drv["body"] = "CHANGE_Value";// + row["body"].ToString();
    >
    >}
    >
     
    Scott Allen, Aug 31, 2004
    #2
    1. Advertising

  3. Darren Clark

    Darren Clark Guest

    thanks.

    "Scott Allen" <bitmask@[nospam].fred.net> wrote in message
    news:...
    > Hi Darren:
    >
    > This event happens before render but AFTER data binding for the item.
    > If you change the row in the underlying data source it won't be found
    > since the value was already bound to the control. You'll want to
    > change a value in e.Item.Controls collection at this point to a
    > different result to appear on the screen.
    >
    > HTH,
    >
    > --
    > Scott
    > http://www.OdeToCode.com
    >
    > On Tue, 31 Aug 2004 10:57:15 +1000, "Darren Clark"
    > <> wrote:
    >
    > >I am trying to work out how to change some values of data during
    > >itemdatabound.
    > >
    > >MSDN states that the ItemDataBound is called BEFORE the render... so any
    > >changes do the data SHOULD work..
    > >
    > >however ihave the following example... and it doesnt work at all... the
    > >text CHANGE_Value does not come up at any time...
    > >
    > >
    > >public void rptList_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
    > >
    > >{
    > >
    > >DataRowView drv = (DataRowView) e.Item.DataItem;
    > >
    > >if (drv == null)
    > >
    > >return;
    > >
    > >drv["body"] = "CHANGE_Value";// + row["body"].ToString();
    > >
    > >}
    > >

    >
     
    Darren Clark, Aug 31, 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. René Paschold

    Re: ItemDataBound in Repeater: FYI

    René Paschold, Oct 14, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    417
    René Paschold
    Oct 16, 2003
  2. Josh Daws
    Replies:
    2
    Views:
    21,999
    Claes
    Sep 11, 2006
  3. =?Utf-8?B?S2V2aW4gSGVjdG9y?=

    Repeater ItemCreated vs ItemDataBound

    =?Utf-8?B?S2V2aW4gSGVjdG9y?=, Apr 11, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    9,964
    Teemu Keiski
    Apr 11, 2004
  4. Bryan
    Replies:
    1
    Views:
    3,566
    =?Utf-8?B?SEFSSSBQUkFTRCBCQVJV?=
    Oct 26, 2004
  5. Dennis E. Jones, Jr.

    Repeater - ItemDataBound and ItemCreated

    Dennis E. Jones, Jr., Nov 18, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    15,917
    Dennis E. Jones, Jr.
    Nov 18, 2005
Loading...

Share This Page