html - ASP.NET Dynamically creating HTMLTableColumns (headers) -
Is it possible that the HTML table column (& lt; th> & lt; / th>) is dynamic with names Make the form. UI.HtmlControls?
Try this:
HtmlTable table1 = new HtmlTable () ; // Set the formatting-related property of the table Table 1. Board = 1; Table 1 Cell padding = 3; Table 1 Cell spacing = 3; Table 1 Border = "red"; // Start adding content to the table HtmlTableRow; HtmlTableCell cell; For (int i = 1; i & lt; = 5; i ++) {// Create a new row and set its background color = new HtmlTableRow (); Line.bugger = (i% 2 == 0 "light": "lightsen"); For (int j = 1; j & lt; = 4; j ++) {// Create a cell and set its text cell = new HtmlTableCell (); Cell.InnerHtml = "line:" + i.ToString () + "
cell:" + j.ToString (); // add cell to existing row row.Cells.Add (cell); } // Add the row to the table. Table1.Rows.Add (line); } // Add the page to this.Controls.Add (table1);
Comments
Post a Comment