ItemDataBound of repeater... Before or after render?

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

}
 
S

Scott Allen

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,
 
D

Darren Clark

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

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top