Repeater does not fire ItemCommand

204 views Asked by At

I Have read similar questions and answers to my question, and I have done the recommendations but still my problem is unsolved PLZ don't mark my question as repetitive.

I have a repeater which contains a tag. I want when user click this link , itemcommend of repeater fire. I have set itemcommand for repeater but it does not fire. My page viewstate is true and my repeater just bind one time. this is my asp code:

<asp:Repeater ID="Rep" runat="server" onitemcommand="Repeater1_ItemCommand"  EnableViewState="true">
    <ItemTemplate>
        <a  id="linkq" commandname="link" runat="server" href='<%# Eval("url") %>'  > <%# Eval("title") %> </a> 
        <%# Eval("url")%> </span>
        <%# Eval("description")%> </span>
    </ItemTemplate>
</asp:Repeater>

This is my c# code:

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        // I Bind  Repeater here
    }
}

protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
    if (e.CommandName == "link")
    {
    }
}
1

There are 1 answers

9
Brian Pechkis On BEST ANSWER

In this situation, I normally use a LinkButton instead of the <a> tag.

<asp:LinkButton ID="linkq" CommandName="link" runat="server"> <%# Eval("title") %> </asp:LinkButton>