Actually there is a table on the page. This table dynamically adds information from the database. It is required to add buttons to the last cell of the table and attach events to them. There are no problems with adding new cells: row.Cells.Add(new TableCell { Text = reader.GetValue(1).ToString() }); As there are no problems with adding the rows themselves to the table: Table1.Rows.Add(row); But using row.Cells.Add(new TableCell { Controls.Add(new Button { Text = "test" }) }); results in the error "Cannot initialize the type" TableCell "by the dialing initializer, because it does not implement the interface" System.Collections.IEnumerable "." Actually, how can I add a button to a table cell?

    1 answer 1

     TableCell cell = new TableCell(); cell.Controls.Add(new Button() { Text = "test" }); row.Cells.Add(cell); 

    or

     row.Cells.Add(new TableCell()); row.Cells[row.Cells.Count - 1].Controls.Add(new Button() { Text = "test" });