Reputation: 21
i have an asp.table where all the cells contains text and the following function to add buttons to the cells
Button btnactiv = new Button();
btnactiv.ID = y.ToString();
btnactiv.Text = "Dept " + dr_depts["code_dept"].ToString() + "(" + nbr + " )";
cell.Controls.Add(btnactiv);
the buttons are added and it works fine but the text of cells gets deleted after i add the buttons how can i add butoons and keep the text please ?
Upvotes: 0
Views: 875
Reputation: 300
first dynamically create a table cell and then add your text and button to it:
TableCell commentCell = new TableCell();
Label lblComment = new Label();
lblComment.Text = "Text to remain in the cell."
commentCell.Controls.Add(lblComment);
Button btnactiv = new Button();
btnactiv.ID = y.ToString();
btnactiv.Text = "Dept " + dr_depts["code_dept"].ToString() + "(" + nbr + " )";
commentCell.Controls.Add(btnactiv);
Upvotes: 2