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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:48:14+00:00 2026-06-13T10:48:14+00:00

<table id=tableContent border=1 runat=server> <tr> <td colspan=3> Record 1 </td> </tr> <tr> <td>1</td> <td>2</td>

  • 0
<table id="tableContent" border="1" runat="server">
    <tr>
        <td colspan="3">
        Record 1
        </td>
    </tr>
    <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
    </tr>
    <tr>
        <td>a</td>
        <td>b</td>
        <td>c</td>
    </tr>
    <tr>
        <td>m</td>
        <td>n</td>
        <td>o</td>
    </tr>
    <tr>
        <td colspan="3">
            <input id="Button1" type="button" value="button" />
        </td>
    </tr>
</table>

I have to create above table dynamically in c#
I am trying but didnt get

protected void Page_Load(object sender, EventArgs e)
{

    HtmlTableRow row = null;
    HtmlTableCell cell = null;

    for(int i = 0; i < 5; i++)
    {
        row = new HtmlTableRow();
        cell = new HtmlTableCell();
        tableContent.Controls.AddAt(i, row);
        row.Controls.AddAt(i, cell);
        cell.InnerText="1";
    }
}
  • 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-13T10:48:15+00:00Added an answer on June 13, 2026 at 10:48 am

    You can try this code to create table.

    First place this markup in your aspx page like

    <table id="tableContent" border="1" runat="server"></table>
    

    Then Try This code in Page_Load like

    protected void Page_Load(object sender, EventArgs e)
    {
        HtmlTableRow row = new HtmlTableRow();
        HtmlTableCell cell = new HtmlTableCell();
    
        cell.ColSpan =3;
        cell.InnerText = "Record 1";
        row.Cells.Add(cell);
        tableContent.Rows.Add(row);
    
        row = new HtmlTableRow();
        cell = new HtmlTableCell();
    
        cell.InnerText = "1";
        row.Cells.Add(cell);
    
        cell = new HtmlTableCell();
        cell.InnerText = "2";
        row.Cells.Add(cell);
    
        cell = new HtmlTableCell();
        cell.InnerText = "3";
        row.Cells.Add(cell);
    
        tableContent.Rows.Add(row);
    
        row = new HtmlTableRow();
        cell = new HtmlTableCell();
    
        cell.InnerText = "a";
        row.Cells.Add(cell);
    
        cell = new HtmlTableCell();
        cell.InnerText = "b";
        row.Cells.Add(cell);
    
        cell = new HtmlTableCell();
        cell.InnerText = "c";
        row.Cells.Add(cell);
    
        tableContent.Rows.Add(row);
    
    
        row = new HtmlTableRow();
        cell = new HtmlTableCell();
        cell.InnerText = "m";
        row.Cells.Add(cell);
    
        cell = new HtmlTableCell();
        cell.InnerText = "n";
        row.Cells.Add(cell);
    
        cell = new HtmlTableCell();
        cell.InnerText = "o";
        row.Cells.Add(cell);
    
        tableContent.Rows.Add(row);
    
        row = new HtmlTableRow();
        cell = new HtmlTableCell();
    
        HtmlInputButton input = new HtmlInputButton();
        input.ID = "Button1";
        input.Value = "button";
    
        cell.ColSpan = 3;
        cell.Controls.Add(input);
        row.Cells.Add(cell);
        tableContent.Rows.Add(row);
    }
    

    Or You can try this, by storing cell values in 2D Array like

    protected void Page_Load(object sender, EventArgs e)
    {
        String[,] cellValues = { { "1", "2", "3" }, { "a", "b", "c" }, { "m", "n", "o" } };
    
        HtmlTableRow row = new HtmlTableRow();
        HtmlTableCell cell = new HtmlTableCell();
    
        cell.ColSpan = 3;
        cell.InnerText = "Record 1";
        row.Cells.Add(cell);
        tableContent.Rows.Add(row);
    
        for (int i = 0; i < cellValues.GetLength(0); i++)
        {
            row = new HtmlTableRow();
            for (int j = 0; j < cellValues.GetLength(1); j++)
            {
                cell = new HtmlTableCell();
                cell.InnerText = cellValues[i, j];
                row.Cells.Add(cell);
            }
            tableContent.Rows.Add(row);
        }
    
        row = new HtmlTableRow();
        cell = new HtmlTableCell();
    
        HtmlInputButton input = new HtmlInputButton();
        input.ID = "Button1";
        input.Value = "button";
    
        cell.ColSpan = 3;
        cell.Controls.Add(input);
        row.Cells.Add(cell);
        tableContent.Rows.Add(row);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple table: -- ---------------------------- CREATE TABLE `clothes` ( `id` int(11) NOT
I have a table I'm working with that is like such: <table width=100% border=0
I have a mysql table with following columns: filterid productid value groupid I want
I have NH mapping public class TblContentMap : ClassMap<TblContent> { public TblContentMap() { Table(tbl_content);
Table A has two columns: ID and name I want to input 3 ID
Table #1: qa_returns_items Table #2: qa_returns_residues I have a long time trying to get
Table: items Create Table: CREATE TABLE `items` ( `ite_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
table is CREATE TABLE `news` ( `id` bigint(20) NOT NULL auto_increment, `title` varchar(255) default
My nested set table is as follows. create table depts ( id int identity(0,
in my jsp i have a table constructed dynamically like the following: ' retour.append();

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.