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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:29:21+00:00 2026-05-31T21:29:21+00:00

I have a table with data from an SQL database and the table exists

  • 0

I have a table with data from an SQL database and the table exists of a few rows and columns.
The user has to provide credentials first before the table with the data is shown so i create the table (and its contents) dynamically.

On each row in the table i add a cell with a “remove”-button in it:

   // more code to create the table above
   Button remove = new Button();
   remove.Text = "Remove";
   remove.Click += new EventHandler(remove_Click);

   TableCell last = new TableCell();
   last.Controls.Add(remove);

   row.Cells.Add(last);
   //...

When the user clicks the button i want the corresponding record in the database to be removed and the table updated after the postback.

The code for this is written in remove_Click but the event is never fired, just because the remove button doesn’t exist anymore after the postback and thus the event of the button can’t be fired.
As explained here: Dynamically Added Event Handler Not Firing

The code works fine if i don’t remove the button, but how would i go about firing the event and still wanting to remove the button ?

  • 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-31T21:29:22+00:00Added an answer on May 31, 2026 at 9:29 pm

    Call whatever function that builds your table AGAIN in the remove_Click event handler. Since the record doesn’t exist in the database after the remove button fires, the 2nd time the BuildTable() is called, that record will not be included when the table is built.

    Assuming your .aspx looks something like:

    ...
    <asp:PlaceHolder id="phTable" runat="server">
    ...
    

    Try something like this:

        PageLoad(...)
        {
            BuildTable();
        }
        BuildTable()
        {
            phTable.Controls.Clear();
            Table T = new Table();
             //do stuff
            phTable.Controls.Add(T);
    
    
        }
        protected void remove_Click(object sender, EventArgs e)
        {
            //remove record from database
            BuildTable();
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an user defined table function in SQL Server that aggregate data from
I have table rows of data in html being filled from a CGI application.
I have a table of data sorted by date, from which a user can
I have data from a table in a database (string) that contain text and
I have a column in the database (SQL Server 2005) that has data with
I have a Microsoft SQL Server 2008 query that returns data from three tables
I have a .sql file from a MySQL dump containing tables, definitions and data
I have a calendar table with data from year 2000 to 2012 (2012 wasn't
I am importing massive amounts of data from Excel that have various table layouts.
I have a main table that I must get data from. I have a

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.