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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:13:13+00:00 2026-05-27T22:13:13+00:00

My newly created button in my gridviewrow is not firing its EventHandler or the

  • 0

My newly created button in my gridviewrow is not firing its EventHandler or the RowCmmand Event and then when the page Reload after pressing the Button newly added row is missing probably because I can’t call my BindData method. I have removed the Click eventHandler from the Button and just used the OnRowCommand Event and I still am getting nothing

protected void CustomGridView_DataBound(object sender, EventArgs e)
{
    int count = ((GridView)sender).Rows.Count;
    GridViewRow row = new GridViewRow(-1, -1, DataControlRowType.DataRow, DataControlRowState.Insert);

    TableCell cell = new TableCell();
    Button button = new Button();
    button.Text = "Insert";
    button.ID = "Insert";
    button.CommandName = "Insert";
    button.Click += new EventHandler(insertButton_Click);

    cell.Controls.Add(button);
    row.Cells.Add(cell);

    for (int i = 0; i < ((GridView)sender).Columns.Count; i++)
    {
        cell = new TableCell();
        cell.Controls.Add(new TextBox { ID = "Text" + i });
        row.Cells.Add(cell);
    }

    Table table = ((GridView)sender).Rows[0].Parent as Table;
    table.Rows.AddAt(count + 1, row);
}

protected void insertButton_Click(object sender, EventArgs e)
{
    lblInsert.Text = "Hello World";
}

protected void CustomGridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "Insert")
    {
        lblInsert.Text = "Hello World";
    }
}
  • 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-05-27T22:13:14+00:00Added an answer on May 27, 2026 at 10:13 pm

    Remove the button.Click += new EventHandler(insertButton_Click); statement from your code. The RowCommand event of GridView controll will be fired when button is pressed. For more info – How to: Respond to Button Events in a GridView Control.

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

Sidebar

Related Questions

Is it bad javascript practice to not assign a newly created object to a
How can I send a variable with a newly created EventHandler? The code I
http://jsfiddle.net/herrturtur/ExWFH/ To try this: click the plus button, double click the newly created name
In a newly created MVC project, in the Account Register page, if I don't
I have newly created a WCF and m facing 400 bad req error when
I'm trying to insert several newly created items to the database. I have a
I have this problem getting my newly created php project on Netbeans work on
I'm trying to add results from an object to newly created HTML elements: *long
I'm trying to assign integer to a newly created row: INSERT INTO wcategory (name,
How do I set default C/C++ compiler options for all newly created projects in

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.