Learn how to a build a cloud-first strategyRegister Now


how to create an html table from server side in asp.net 2.0

Posted on 2007-07-25
Medium Priority
Last Modified: 2008-01-09
I have a web page and in that i want to display all the records from a table in a tabular form on the web page and i donot want to use datagrid control

but i donot want to write any server side coding on the html part.
so how can i create a html table from the server side and them add it to the html part at runtime.
Question by:ziorrinfotech

Accepted Solution

Chirag1211 earned 260 total points
ID: 19572170
You can create object of HtmlTable in your server side code. And on the aspx page you can place a asp:panel object. So that on server-side code when you have prepared the HTMLTable you can directly write aspPanelObject.Controls.Add(HTMLTableObject). This will render your HTML Table on your aspx page at runtime.

For more Information see the link below:


Chirag Patel

Assisted Solution

zeroxp earned 240 total points
ID: 19613789
you can construct your table on the server side with the System.Web.UI.WebControls.Table. just add rows and cells to it. here is an example you can get a bit idea from it. after you table have all the rows and cells, you can append that to a location on the form. if you data is in a datatable, you can use GridView or DataGrid to display that in a table. here is a good article on using grid http://www.developer.com/net/asp/article.php/2210191

// example in C#
         Table tbl = new Table();
         TableRow row;
         TableCell cell;
         TextBox txt;
         cell = new TableCell();
         cell.Text = "Name:";
         row = new TableRow();
         txt = new TextBox();
         txt.Text = "Robot";
         cell = new TableCell();

         cell = new TableCell();
         cell.Text = "Company Name:";
         row = new TableRow();
         txt = new TextBox();
         txt.Text = "The Machine Company";
         cell = new TableCell();
         tbl.GridLines = GridLines.Both;
         tbl.CellPadding = 0;
         tbl.CellSpacing = 0;
         tbl.Width = Unit.Percentage(100);

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question