Saturday, February 12, 2011

The gridview fired event RowEditing which wasn't handled

Problem:
I ran into this problem with the following code:
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:LinkButton ID="btnCC2" runat="server"
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Id", "{0}") %>'
CommandName="Edit" OnCommand="btnCC_Click">
Edit
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>

ASP.NET apparently thinks any control with "Edit" as the CommandName is supposed to be calling the RowEditing function.

Solution:
To fix this, change CommandName to something else. I changed mine to CommandName="EditCC"

No comments:

Post a Comment

There was an error in this gadget