DataRepeater FindControl("controlX") ControlX was added to placeho


G

Guest

Hello,

I have a repeater control with a placeholder inside ItemTemplate.
myRpt_ItemDataBound() event adds dropdown conrol (drpCntlr.ID = ControlX) to
a place holder.
Then on postback, I want to read this value selected by a user:

drpX = (DropDownList)rptSelect.Items.FindControl("ControlX");

but drpX is null.
How can I get the value of a control which was added dynamically to a
placeholder?

Thank you
 
Ad

Advertisements

T

Teemu Keiski

Hi,

you'd need to add it in ItemCreated so that control instance exists also on
postback. In ItemdataBound you'd just deal with the data-binding specific
stuff, not control creation (if you need to check from data which type of
control to create, you can do that in ItemCreated when e.Item.DataItem is
not null, that is true when ItemCreated runs just before ItemdataBound e.g
on DataBind() call)
 

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

Top