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 8730303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:59:37+00:00 2026-06-13T08:59:37+00:00

I have a gridview with a delete button. I’ve added a messagebox with an

  • 0

I have a gridview with a delete button. I’ve added a messagebox with an ‘are you sure’ yes/no. The row of data is deleted fine when you click yes, but the gridview data disappears if you click no.

Here’s the code for the delete button click:

private void gvOrderLines_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
    int intOrderID = 0;

    if (e.RowIndex < 0 || e.ColumnIndex != gvOrderLines.Columns["deleteBtn"].Index) return;

    Int32 orderLineID = (Int32)gvOrderLines[1, e.RowIndex].Value;

    DialogResult result = MessageBox.Show("Do you want to delete this item? ","Delete Item",MessageBoxButtons.YesNo);

    if (result == DialogResult.Yes)
    {
        using (SqlConnection conn = new SqlConnection(connection))
        {

            SqlCommand comm;

            comm = new SqlCommand("del_OrderLine", conn);
            comm.CommandType = CommandType.StoredProcedure;

            comm.Parameters.Add(new SqlParameter("@orderLineID", SqlDbType.Int));
            comm.Parameters["@orderLineID"].Value = orderLineID;

            comm.Parameters.Add("@ReturnValue", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;

            try
            {
                conn.Open();
                comm.ExecuteNonQuery();

                intOrderID = (int)comm.Parameters["@ReturnValue"].Value;
            }
            catch 
            { 
                //tba
            }
            finally
            {
                comm.Dispose();
                conn.Close();
            }
        }
    }
    populateOrderLines(intOrderID); // This repopulates the gv so why is it blank?
    populateOrderTotals(intOrderID);
}

Any suggestions?

All the best,
Numb

  • 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-13T08:59:38+00:00Added an answer on June 13, 2026 at 8:59 am

    Put these lines within the if (result == DialogResult.Yes) block:

    populateOrderLines(intOrderID); // This repopulates the gv so why is it blank?
    populateOrderTotals(intOrderID);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a delete button in each row of GridView (component ASP.NET). I want
I have a delete button in my gridview, but I want this button not
I have a delete button on a gridview for each row that calls gvSiteInfo_RowDeleting(object
I have a gridview control with delete asp:ImageButton for each row of the grid.
I have a delete button in a gridview. For those not familiar with asp.net
I have a gridview and i have two buttons edit and delete.Once i click
I have a gridview which has an asp image-button for deleting a row. I
I have a Gridview., usually, when the delete command button is clicked then the
I have a gridview with edit and delete buttons on each row. I am
I have added a button column to a gridview. I am populating the gridview

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.