J
jsever05
I have looked around the web for a solution to this, but I can't find
it. It's probably something simple I have overlooked.
I am trying to build a dynamic table on the server-side and render its
contents to the .aspx page. I placed the following code on the .aspx
page:
<asp:Table id="TestTable" runat="server"></asp:Table>
Then in my page class, I added the following member variable:
System.Web.UI.HtmlControls.HtmlTable TestTable;
Finally, in the Page_Init() function I added the following code:
TestTable = new HtmlTable();
HtmlTableRow theRow = new HtmlTableRow();
TestTable.Rows.Add(theRow);
HtmlTableCell theCell = new HtmlTableCell();
theRow.Cells.Add(theCell);
HyperLink theLink = new HyperLink();
theCell.Controls.Add(theLink);
theLink.Target = "StatusOrders.aspx";
theLink.ID ="link1";
theLink.Text = "Test Text aaaaa";
When I run the code, the only thing that renders as HTML is:
<table id="TestTable" border="0"></table>
I get nothing for the row, cell, or link that I added. I tried putting
this code in the Page_Load() event, the Page_Init() event, and a
constructor function that I created for the page object, and it doesn't
change. Can someone help me to render this properly?
Thanks!
it. It's probably something simple I have overlooked.
I am trying to build a dynamic table on the server-side and render its
contents to the .aspx page. I placed the following code on the .aspx
page:
<asp:Table id="TestTable" runat="server"></asp:Table>
Then in my page class, I added the following member variable:
System.Web.UI.HtmlControls.HtmlTable TestTable;
Finally, in the Page_Init() function I added the following code:
TestTable = new HtmlTable();
HtmlTableRow theRow = new HtmlTableRow();
TestTable.Rows.Add(theRow);
HtmlTableCell theCell = new HtmlTableCell();
theRow.Cells.Add(theCell);
HyperLink theLink = new HyperLink();
theCell.Controls.Add(theLink);
theLink.Target = "StatusOrders.aspx";
theLink.ID ="link1";
theLink.Text = "Test Text aaaaa";
When I run the code, the only thing that renders as HTML is:
<table id="TestTable" border="0"></table>
I get nothing for the row, cell, or link that I added. I tried putting
this code in the Page_Load() event, the Page_Init() event, and a
constructor function that I created for the page object, and it doesn't
change. Can someone help me to render this properly?
Thanks!