repeater question

G

Guest

Hello,
I want to set a unique id for each item in a repeater like this:

<asp:repeater id=__theTabStrip runat="server" DataSource='<%#
DataBinder.Eval(Container,"TabText") %>'>
<ItemTemplate>
<asp:Button Runat="server" id="<%# Container.DataItem %>" BackColor="<%#
SetTabBackColor(Container) %>" />
</ItemTemplate>
</asp:repeater>

However, the id="<%# Container.DataItem %>" generates an error:'<%#
Container.DataItem %>' is not a valid identifier.

Would someone please tell me what I did wrong?
 
K

Karl Seguin

Id's can't be determined at databound time, they must be determined earlier.
Besides, there's no reason why you'd want a unique id. You don't access a
control like this by id, but rather use a FindControl() of the individual
repeateritem.

Check out:
http://openmymind.net/index.aspx?documentId=8#4.2
for an example.

karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 

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

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top