locked
The GridView 'GridView1' fired event RowEditing which wasn't handled RRS feed

  • Question

  • User773777300 posted

    When i tried to build the project it wont shows error.But When i Clicked the edit button for  gridview control i got a error.suggest me how to rectifier the error.

    Server Error in '/WebSite' Application.


    The GridView 'GridView1' fired event RowEditing which wasn't handled.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.Web.HttpException: The GridView 'GridView1' fired event RowEditing which wasn't handled.

    Source Error: 

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Thursday, November 6, 2014 1:09 AM

All replies

  • User-1716253493 posted

    Please include code snipped

    Thursday, November 6, 2014 1:43 AM
  • User71929859 posted

    You have to implement the RowEditing event in the code behind if you wish to use the edit.

    Your aspx must have the editing event defined like below

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" onrowediting="GridView1_RowEditing">

    and in your C# code,

    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
         //Your code related to editing here
    }
    

    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowediting(v=vs.110).aspx

    Thursday, November 6, 2014 5:26 PM
  • User2103319870 posted

    Do you have a button column in your GridView to trigger the Edit Comand .If you have assigned a reserved key word as command name to button then you will get the error.

    <asp:GridView ID="gv1" runat="server" AutoGenerateColumns="False" Width="100%" OnRowCommand="gv1_RowCommand"
                CellPadding="2">
                <Columns>
                    <asp:TemplateField HeaderText="Edit">
                        <ItemTemplate>
                            <asp:Button ID="Button2" runat="server" Text="Edit" CommandName="EDIT" CommandArgument="<%# Bind("ID") %>" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <%--Your other column Here--%>
                </Columns>
            </asp:GridView>

    In above code CommandName is assigned a keyword "Edit".

    You should change it to "EditItem" or something like that.

    Updated Code:

      <asp:GridView ID="gv1" runat="server" AutoGenerateColumns="False" Width="100%" OnRowCommand="gv1_RowCommand"
                CellPadding="2">
                <Columns>
                    <asp:TemplateField HeaderText="Edit">
                        <ItemTemplate>
                            <asp:Button ID="Button2" runat="server" Text="Edit" CommandName="EDITITEM" CommandArgument="<%# Bind("ID") %>" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <%--Your other column Here--%>
                </Columns>
            </asp:GridView>
    Friday, November 7, 2014 12:03 AM
  • User-1526149672 posted

    its work. thank u so much

    Wednesday, January 31, 2018 7:05 AM