I am having problem with my repeater's OnItemCommand event. When I click the Link Button, its not firing. Am I missing any environment variable
ASPX code
<table>
<!-- repResearchers begin, 0=display name, 1=url -->
<asp:Repeater ID="repExtResearchers" Runat="server" OnItemCommand="deleteResearcher">
<ItemTemplate>
<tr>
<td>
<a href="<%# ((System.String[])Container.DataItem)[1] %>">
<%# ((System.String[])Container.DataItem)[0] %></a>
</td>
<td>
<asp:LinkButton ID="lbDelete" runat="server" CommandName="del"
CommandArgument = "<%# ((System.String[])Container.DataItem)[1]%>"
OnClientClick="if (!confirm('Are you sure do you want to delelte it?')) return false;">Delete</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
CS
protected void deleteResearcher(object sender, RepeaterCommandEventArgs e)
{
string a;
lblError.Text = e.CommandArgument.ToString();
lblError.Visible = true;
}
Make sure you dont rebind the repeater at every postback.
If (Page.IsPostBack)
return;
repExtResearchers.DataSource = ...
repExtResearchers.DataBind();
Hope that helps.
I'm sure - as this is an EXTREMELY old question - that this has been answered already, but for people who may be running into what I was running into...
If you're using any of the Ajax Controls, they all require a validation group. I had a really long page that I was trying to shorten by doing this, so I wasn't noticing that the ajax controls from the Ajax Control Toolkit were throwing errors and not validating. I set the LinkButton's validation group to something that was nowhere anywhere and it started firing.
Hopefully, that helps someone out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With