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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:03:06+00:00 2026-05-20T22:03:06+00:00

I Have an ASP:Table that has a row with cells in I need to

  • 0

I Have an ASP:Table that has a row with cells in I need to be able to add a row to this by clicking the Add button at the end which duplicates the existing row.

My Table code

<asp:Table ID="Table1" runat="server" Height="50%" Width="100%">
            <asp:TableHeaderRow CssClass="lblrow2" HorizontalAlign="Left" BackColor="AliceBlue">
                <asp:TableHeaderCell ID="haccountref">Account Ref:</asp:TableHeaderCell>
                <asp:TableHeaderCell ID="hproduct">Product</asp:TableHeaderCell>
                <asp:TableHeaderCell ID="hqty">Qty:</asp:TableHeaderCell>
                <asp:TableHeaderCell ID="hunitprice">Unit Price:</asp:TableHeaderCell>
                <asp:TableHeaderCell ID="hdiscount">Discount:</asp:TableHeaderCell>
                <asp:TableHeaderCell ID="htotal">Total Line Amount:</asp:TableHeaderCell>
            </asp:TableHeaderRow>
            <asp:TableRow CssClass="r1">
                <asp:TableCell><asp:TextBox ID="vaccountref" ReadOnly="True" runat="server"></asp:TextBox></asp:TableCell>
                <asp:TableCell><asp:DropDownList runat="server" ID="vproduct"></asp:DropDownList></asp:TableCell>
                <asp:TableCell><input id="Qty" type="text" /></asp:TableCell>
                <asp:TableCell><input id="Unit Price" type="text" /></asp:TableCell>
                <asp:TableCell><input id="Discount" type="text" /></asp:TableCell>
                <asp:TableCell><input id="Total" type="text" /></asp:TableCell>
                <asp:TableCell><input id="Button1" type="image" src="plusButton.png" value="button" /></asp:TableCell>
            </asp:TableRow>
        </asp:Table>

My c# code behind – I get no errors but no duplicate row

protected void Button1_Click(object sender, System.EventArgs e)
        {
            // Total number of rows.
            int rowCnt;
            // Current row count.
            int rowCtr;
            // Total number of cells per row (columns).
            int cellCtr;
            // Current cell counter
            int cellCnt;

            rowCnt = int.Parse(TextBox1.Text);
            cellCnt = int.Parse(TextBox2.Text);

            for (rowCtr = 1; rowCtr <= rowCnt; rowCtr++)
            {
                // Create new row and add it to the table.
                TableRow tRow = new TableRow();
                Table1.Rows.Add(tRow);
                for (cellCtr = 1; cellCtr <= cellCnt; cellCtr++)
                {
                    // Create a new cell and add it to the row.
                    TableCell tCell = new TableCell();
                    tCell.Text = "Row " + rowCtr + ", Cell " + cellCtr;
                    tRow.Cells.Add(tCell);
                }
            }
        }
  • 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-20T22:03:07+00:00Added an answer on May 20, 2026 at 10:03 pm

    Ensure that you’re actually using an ASP.NET server control button. You’re currently using an HTML input image/button. It won’t post back for the server to capture that event.

    Try this as the last column in your table with an <asp:ImageButton> server control.

    <asp:TableCell>
        <asp:ImageButton id="Button1"  runat="server" 
             ImageUrl="plusButton.png"   OnClick="Button1_Click" />
    </asp:TableCell>
    

    That should replace: <input id="Button1" />

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

Sidebar

Related Questions

I have a table that per row has some inputs and one edit button.
I have an ASP.NET GridView which has columns that look like this: | Foo
i have a table which looks similar to this <asp:TableRow><asp:TableCell>Question 1</asp:TableCell><asp:TableCell ID =Question1Text></asp:TableCell></asp:TableRow> <asp:TableRow><asp:TableCell
I have a table that has Edit and Delete links in each row. I
I have a asp.net Generated table that creates a table which is slide show
I have a table that is created in a DataList in ASP.Net. This table
I have a web page that has an HTML table generated by an ASP.NET
I have a VS2010 ASP.Net webform that contains a GridView. This GridView has ShowHeaderWhenEmpty=True
How can I loop through table and row that have an attribute id or
I have an ASP.NET MVC3 app that features a form with a nested-table input

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.