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

  • SEARCH
  • Home
  • 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 9149857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:32:02+00:00 2026-06-17T11:32:02+00:00

How can I delete, edit and add rows in a gridview with 3 buttons

  • 0

How can I delete, edit and add rows in a gridview with 3 buttons out of it for deleting, editing and adding rows in C# asp.net and refresh grid after changing?
I don’t want to use the command buttons of the gridview that is repeated in every row.

  • 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-17T11:32:03+00:00Added an answer on June 17, 2026 at 11:32 am

    You need to select the row some how in order for the code to know which row to delete or edit. Then you can grab the the content of that row on GridView1_SelectionChanged in order to delete or update it.

    Edit:
    Here is what to do:
    1. Drag a gridview and a textbox to page.
    2. Populate gridview
    3. Override Render

    protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            foreach (GridViewRow row in GridView1.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    row.Attributes["onclick"] =ClientScript.GetPostBackClientHyperlink(GridView1,
                "Select$" + row.DataItemIndex, true);
                }
            }
            base.Render(writer); 
        }
    

    4) In GridView1_SelectedIndexChanged event

    //retrieve the id for selected row
    int id=int.Parse(GridView1.SelectedDataKey.Value.ToString());
    GridViewRow row = GridView1.SelectedRow;
    TextBox1.Text = row.Cells[0].Text;
    

    Now you can easily customize this simple example up to your taste.

    Edit 2:
    Specify the Id as DataKeyName in gridview

     <asp:GridView ID="GridView1" runat="server" DataKeyNames="id"
                    onselectedindexchanged="GridView1_SelectedIndexChanged">
    

    Check the updated GridView1_SelectedIndexChanged to see how to retrieve the id for selected row.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apple's documentation on UITableView discusses how to add/edit/delete rows, but it doesn't discuss adding/editing/deleting
I have a gridview, where i can add/delete rows. I dont want to give
how I can access a DataSet and it's TablesData (s) to add/delete/edit rows from
I'm using jqGrid with inlineNav so that users can edit/add/delete rows locally and then
i`m trying to make an NSMutableArray From NSUserDefaults so i can add/delete and edit
I have a simple form where a user can add, edit, and delete people
I trying to figure out how I can delete from multiple tables in SQL
I am developing UI form that has infragistics grid. Users can delete, submit some
I am working on a site that users can add and delete videos from
I have a gridview that I want to read, delete, edit and update, I

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.