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
I'm trying to insert several newly created items to the database. I have a
I am trying to add data to a newly created column... DataSet ds =
How do I set default C/C++ compiler options for all newly created projects in
I am attempting to create a Stored Procedure for a newly created database. However
I am contemplating writing a program that will move some newly created dirs to
I would like to return the id of a newly created object for my
Any advice on how to read auto-incrementing identity field assigned to newly created record
I am new to git and when I try to upload my newly created
What gives? My previously created user control is visible, but the newly created one

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.