I have this table in my Page.aspx
<asp:Table ID="table1" runat="server" CssClass="tabla" ></asp:Table>
I am building dynamically table1
in my Page.aspx.cs from a list using a foreach, adding 3 cells:
TableCell cell_name = new TableCell();
cell_name.Text = "Some name";
TableCell cell_active = new TableCell();
CheckBox checkbox = new CheckBox();
cell_active.Controls.Add(checkbox);
TableCell cell_actions = new TableCell();
ImageButton button = new ImageButton();
cell_actions.Controls.Add(button);
TableRow row = new TableRow();
row.Cells.Add(cell_name);
row.Cells.Add(cell_active);
row.Cells.Add(cell_actions);
table1.Rows.Add(row);
I want my ImageButton to have a onClick event and get from there the table row id (index inside the table) for the parent row of my ImageButton that was clicked. Is that possible? Any ideas?
Copyright Notice:Content Author:「anairinac」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/21200212/how-to-get-a-table-row-from-a-control-inside-a-cell