i




 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to create TABLE Dynamically in asp.net.
02-14-2011, 04:04 PM
Post: #1
Solved: Today Today how to create TABLE Dynamically in asp.net.
hi friends,

how to create TABLE Dynamically in asp.net.

please give in detail.

thanks.



Thanks & Regards,
Quote
02-14-2011, 05:24 PM
Post: #2
Solved: Today Today RE: how to create TABLE Dynamically in asp.net.
you need to create htmltable object to meet your requirements
below is a sample code to create html table at runtime, it will create 2rows and 3 columns in each row.
Code:
protected void Page_Load(object sender, System.EventArgs e)
        {
            // Create a new HtmlTable object.
            HtmlTable table1 = new HtmlTable();

            // Set the table's formatting-related properties.
            table1.Border = 1;
            table1.CellPadding = 1;
            table1.CellSpacing = 1;
            table1.BorderColor = "red";

            // Start adding content to the table.
            HtmlTableRow row;
            HtmlTableCell cell;
            for (int i = 1; i <= 2; i++)
            {
                // Create a new row and set its background color.
                row = new HtmlTableRow();
                row.BgColor = "lightyellow";
                for (int j = 1; j <= 3; j++)
                {
                    // Create a cell and set its text.
                    cell = new HtmlTableCell();
                    cell.InnerHtml = "Row: " + i.ToString() + "<br />Cell: " + j.ToString();
                    // Add the cell to the current row.
                    row.Cells.Add(cell);
                }

                // Add the row to the table.
                table1.Rows.Add(row);
            }

            // Add the table to the page.
            this.Controls.Add(table1);
        }

Don't forget to add
Code:
using System.Web.UI.HtmlControls;

[Image: 2604595733.png]
Quote
02-14-2011, 07:06 PM
Post: #3
Solved: Today Today RE: how to create TABLE Dynamically in asp.net.
thanks..

Thanks & Regards,
Quote


Possibly Related Threads...
Thread: Author Replies Views: Last Post
  Can use SQL Server 2005 to Connection (link table) mySQL table ? dongtrien 5 689 08-22-2013 10:43 AM
Last Post: magnum_2007
  Dynamically add new row in grid asp.net anghanneil@gmail.com 2 1,146 01-29-2013 11:09 AM
Last Post: nisar87
  How to create virtual keyboard in asp.net MaruthiRam_99 3 1,879 01-16-2013 12:35 PM
Last Post: magnum_2007
  create new row at runtime in asp.net(c#) fardin_esmi 4 2,987 10-30-2012 09:55 AM
Last Post: nisar87
  create dynamic datatable in asp.net raj2sekar1 1 3,103 07-23-2012 07:03 AM
Last Post: nisar87



User(s) browsing this thread: 1 Guest(s)