You must Sign In to post a response.
  • Category: .NET

    How to dynamically bring a table with rows and columns when enter value in textbox

    hai all,
    i have one text box when i enter avalue in textbox and click on generate button the value how much i have entered that many textboxes should be displayed up to this working fine

    but what i want is i want to diplay ablock or table which contains
    firstrow firstcolumn is username:
    firstrow 2ndcolumn is textbox

    2ndrow firstcolumn is password:
    2nd row 2nd column is textbox
    3rd row first column is button

    so like this atable should come like this if i enter 3 in textbox and click on generate button 3 tables should come

    below is my code any body helpme or give examples
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public partial class dynamic : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

    protected void Page_Init(object sender, EventArgs e)
    if (!IsPostBack)
    //Generate initial textboxes
    GenerateButton_Click(sender, e);

    }protected void GenerateButton_Click(object sender, EventArgs e)
    int z = int.Parse(HowManyToGenerateTextBox.Text);


    for (int i = 0; i < z; i++)
    Table l = new Table();

    TextBox s = new TextBox();

    s.Text = i.ToString();
    s.ID = "tb" + i.ToString();
    Session[s.ID] = s;


  • #762694
    If you want to generate the Table dynamically, you need to write the HTML code and then add the controls based on your requirements.
    To create a new row, you can use :

    TableRow tr = new TableRow();

    To create the column dynamically, you can use:

    TableCell tc = new TableCell();

    Hope it will be helpful to you.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • Sign In to post your comments