Im rendering an html table on the page_load event. I would then like to submit the table on button click and read the contents of each cell. Here is the code that i have created to create the table.
<html>
<script runat="server" >
void Page_Load(Object sender, EventArgs e)
{
// Create the HtmlTable control.
HtmlTable table = new HtmlTable();
table.Border = 1;
table.CellPadding = 3;
table.ID = "testTable";
// Populate the HtmlTable control.
// Create the rows of the table.
for(int rowcount=0; rowcount<5; rowcount++)
{
HtmlTableRow row = new HtmlTableRow();
// Create the cells of a row.
for(int cellcount=0; cellcount<4; cellcount++)
{
HtmlTableCell cell;
// Create table header cells for first row.
if(rowcount <= 0)
{
cell = new HtmlTableCell("th");
}
else
{
cell = new HtmlTableCell();
}
// Create the text for the cell.
cell.Controls.Add(new LiteralControl(
"row " + rowcount.ToString() + ", " +
"column " + cellcount.ToString()));
// Add the cell to the Cells collection of a row.
row.Cells.Add(cell);
}
// Add the row to the Rows collection of the table.
table.Rows.Add(row);
}
// Add the control to the Controls collection of the
// PlaceHolder control.
Place.Controls.Clear();
Place.Controls.Add(table);
}
</script>
<body>
<form id="Form1" runat="server">
<h3> HtmlTable Example </h3>
<asp:PlaceHolder id="Place" runat="server"/>
<asp:Button runat="server" Text="click me!" OnClick="Unnamed_Click" />
</form>
</body>
</html>
This is pretty simple stuff however i don't know how to begin reading the data from the html table once i capture the button click event. I would appreciate any help you guys can offer. i try looking at this post but they are just not making sense?...
Note: Once i render the table, it could get manipulated by users using javscript on the page. Therefore a data bound does not seem to be doable here.(I could be wrong though.) I also see alot mentions of the html agility pack, though it seems for like what im doing is not necessary.