I have a Repeater control with a Rating control (from the latest AJAX Control Toolkit) inside:
<asp:Repeater ID="repStudents" runat="server" onitemcommand="repStudents_ItemCommand">
<ItemTemplate>
<%# Eval("FirstName") %>
<asp:Rating ID="warnings" runat="server" Direction="NotSet" MaxRating="3" StarCssClass="star" EmptyStarCssClass="em" FilledStarCssClass="gr" WaitingStarCssClass="gr" AutoPostBack="True" CommandArgument='<%# Eval("Id") %>' CommandName="warn"></asp:Rating>
<br />
</ItemTemplate>
</asp:Repeater>
In the code behind, I have:
protected void repStudents_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
{
//Custom log function
Log.Append(e.CommandName + " " + e.CommandArgument);
}
All renders fine. However, when I click on a rating the page posts back but repStudents_ItemCommand is not fired. How can I fix this?
Note that if I put a Button in the same Repeater, repStudents_ItemCommand fires correctly when I click the button.
The Rating control does not support CommandName/CommandArgument properties. But you can extend it as follows:
Then replace the old control with new one: