On Page_Init, I check if Button1 was pressed, if so I create a series of LiteralControls in a Panel, called Panel1:
Panel1.Controls.Add(new LiteralControl("<table>"));
Panel1.Controls.Add(new LiteralControl("<tr>"));
Panel1.Controls.Add(new LiteralControl("<td>Header 1</td>"));
Panel1.Controls.Add(new LiteralControl("<td>Header 2</td>"));
Panel1.Controls.Add(new LiteralControl("<td>Header 3</td>"));
Panel1.Controls.Add(new LiteralControl("</tr>"));
Panel1.Controls.Add(new LiteralControl("<tr>"));
Panel1.Controls.Add(new LiteralControl("<td>Data 1</td>"));
Panel1.Controls.Add(new LiteralControl("<td>Data 2</td>"));
Panel1.Controls.Add(new LiteralControl("<td><input type=\"text\" name=\"txtCode3\"></td>"));
Panel1.Controls.Add(new LiteralControl("</tr>"));
Panel1.Controls.Add(new LiteralControl("</table>"));
I have a second button, that on click, I want to fill a NameValueCollection (or any other list) with all table cell elements (or values).
How can I do this?
I’ve tried:
protected void Button2_Click(object sender, EventArgs e)
{
NameValueCollection coll = Request.Form;
}
But this only gives me:
AllKeys:
[0] "_VIEWSTATE"
[1] "_EVENTVALIDATION"
[2] "Button2"
[3] "txtCode3"
As you can see, I can’t get all cell elements.
I should get:
AllKeys:
[0] "_VIEWSTATE"
[1] "_EVENTVALIDATION"
[2] "Button2"
[3] Header 1
[4] Header 2
[5] Header 3
[6] Data 1
[7] Data 2
[3] "txtCode3"
Thank you.
I as able to achieve this by switching to an <asp:Table> instead of a plain html table.