Click here to Skip to main content
14,773,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Am using repetor for anchor tag,whenever i bind the data to the repeator the anchor tag id is same for all created anchor tags in repeator because of that i failed to call the script how to solve these issue

Append the unique Id using Eval.

<a id="a_<%# Random() %><%# DataBinder.Eval(Container,"itemindex") %>" />

Random()is a function in your code behind which returns a random number
Member 10226004 30-May-14 5:41am
i need to genarate id for anchor tags in repeator as a1,a2, can i do this if it is in repeator
The individual anchor tags in the repeater will be given unique ids. check this out:
aspx page:
<head runat="server">
        function myfunction(obj) {
    <form id="form1" runat="server">
        <asp:Repeater ID="Repeater1" runat="server">
                <div style="font-weight: bold;">
                    Repeater Demo</div>
                    <a href='<%# Container.DataItem %>' runat="server" onclick="myfunction(this);" id="mylink">
                        <%# Container.DataItem %></a>

code behind:
protected void Page_Load(object sender, EventArgs e)
    List<string> myList = new List<string>();

    Repeater1.DataSource = myList;


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900