on .aspx page I create a placeholder that will contain a Table.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication2.WebForm2" EnableViewState="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
</div>
<asp:PlaceHolder ID="resultHolder" runat="server"></asp:PlaceHolder>
</form>
</body>
</html>
There after define logic on code behind page
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication2
{
public partial class WebForm2 : System.Web.UI.Page
{
static Table tableResult;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
tableResult = new Table();
tableResult.GridLines = GridLines.Both;
TableHeaderRow dr = new TableHeaderRow();
TableHeaderCell dc = new TableHeaderCell();
dc.Text = "Name";
dr.Cells.Add(dc);
tableResult.Rows.Add(dr);
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
TableRow dr = new TableRow();
TableCell dc = new TableCell();
dc.Text = "Sandeep";
dr.Cells.Add(dc);
tableResult.Rows.Add(dr);
resultHolder.Controls.Add(tableResult);
}
}
}
This is basci logic to add a row on button click you can change dynamically text for cell as you want.
Thanks