Setting ID to a control inside repeater itemtemplate
Posted
by toraan
on Stack Overflow
See other posts from Stack Overflow
or by toraan
Published on 2010-04-01T12:42:48Z
Indexed on
2010/04/01
13:13 UTC
Read the original article
Hit count: 244
ASP.NET
Inside repeater's itemtemplate I have a Panel server control.
I need to assign special Id for it, because I need to work with some javascript functions that use this Id.
In repeater ItemDataBound event I have this:
pnlButtonsPanel.ID = pnlButtonsPanel.ID + DataBinder.Eval(e.Item.DataItem, "ID");
But this solution is not good because after a postback the page is re -rendered and I lose the new ID. (And I don't want to rebind repeater after every postback)
I tried to set the ID on aspx page like that:
<asp:Panel id='<%# Eval("ID") %>'
and some other variations but always get compile errors.
© Stack Overflow or respective owner