UPDATE
I should learn to read error messages more carefully. I forgot to change some ID’s in my column specification for the gridview which were the same, which of cause resulted in the “Multiple same ID’s” error.
Thank you for all that read my question and the once trying to help me. Free slaps to my face
I’m trying to get a hold of a OnClick or OnCommand event from an ImageButton that are inside a usercontrol which are inside a GridView. I tried creating the imagebutton so it throws a Command:
<asp:ImageButton runat="server" ID="exchanceButton"
Visible="False" ImageUrl="../Images/Icons/Exchange.png"
CommandName="exchanceCommand" CommandArgument="1">
And the catch it inside the GridView OnRowCommand, but I get the following error: Multiple controls with the same ID ‘userControlPlan’ were found. FindControl requires that controls have unique IDs. I tried debugging but it doesn’t reach my OnRowCommand at all.
I tried the following guide but with no success: http://msdn.microsoft.com/en-us/library/bb907626.aspx
I also tried to carry the event out by creating my own event inside the UserControl and then assign a listener to each UserControl:
public delegate void OnExchanceClickDelegate(int id);
public event OnExchanceClickDelegate OnExchangeClick;
protected void exchanceButton_Click(object sender, ImageClickEventArgs e)
{
if (OnExchangeClick != null)
OnExchangeClick(1);
}
but I get the same error about multiple controls.
Do any of you have any suggestions to how I can raise the event correctly from the ImageButton inside the the UserControl out to the Gridview or something else?
I fixed the problem. I did have duplicate ID’s in my UserControl. I updated my original question.