ItemDataBound of repeater... Before or after render?

  • Thread starter Thread starter Darren Clark
  • Start date Start date
D

Darren Clark

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();

}
 
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,
 
thanks.

Scott Allen said:
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

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();

}
 
Back
Top