Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8713303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:18:39+00:00 2026-06-13T05:18:39+00:00

I added a Delete Command button to my GridView but whenever i chick the

  • 0

I added a Delete Command button to my GridView but whenever i chick the button i get an error which is:

  • [HttpException (0x80004005): The GridView ‘GridView1’ fired event RowDeleting which wasn’t handled.]
  • System.Web.UI.WebControls.GridView.OnRowDeleting(GridViewDeleteEventArgs e) +1463321

but i dont know whats the event that i should use and what to delete and edit, here is my code:

            <asp:TemplateField HeaderText="">
                 <ItemTemplate>
                   <asp:Button ID="lkDelte" runat="server" OnClientClick="return confirm('Are you sure you want to delete?')"
                                CommandName="Delete" CommandArgument='<%# ((GridViewRow) Container).RowIndex %>'></asp:Button>
                   </ItemTemplate>
            </asp:TemplateField>






protected void gdCourse_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "Delete")
    {
        int index = Convert.ToInt32(e.CommandArgument);

        GridViewRow row = GridView1.Rows[index];

        string con_str = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;
        SqlConnection con = new SqlConnection(con_str);

        SqlCommand com = new SqlCommand("dbo.delete_documents", con);
        com.CommandType = CommandType.StoredProcedure;
        SqlParameter pDocument_ID = new SqlParameter("@document_id", row);

        com.Parameters.Add(pDocument_ID);

        con.Open();
        com.ExecuteNonQuery();
        con.Close();

    }
    else
    {
        Label2.Text = "Unable to delete";
    }
}  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:18:40+00:00Added an answer on June 13, 2026 at 5:18 am

    Nothing wrong with your code but you forgot to handle the RowDeleting event of your grid view.

    You need to handle the gridview RowDeleting method:

    protected void gvLineItems_RowDeleting(object sender, GridViewDeleteEventArgs e)

    In this case you can just rebind in this method or leave the method empty but add it’s signature so the event can fire correctly.

    Add this to your program:

    protected void NameOfYourGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
     {
      //bind your grid view here...
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I added an image to button UIImage* deleteImage = [UIImage imageNamed:@Delete.png]; CGRect imageFrame=CGRectMake(-4,-4, 310,
How I can delete an object which I had added before with this code.
I try to delete a record in Gridview and Database .I added a boundfield
i'm trying to delete a record in my gridview. for doing this i added
Suppose I have a list, in which no new nodes are added or deleted.
When running the command svn ci you get a text editor that allows you
I have reminder with a known ID, but couldn't find a solution to delete
I accidentally added '.' to version control and then did svn delete --keep-local .
I have a datagrid buttoncolumn which acts as delete buttons for my xml nodes.
I have datagrid with a delete button XAML looks like: <sdk:DataGridTemplateColumn Header=Del/Tgl > <sdk:DataGridTemplateColumn.CellTemplate>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.