我有一个asp.table,所有单元格都包含文本和下面的函数来向单元格添加按钮
Button btnactiv = new Button();
btnactiv.ID = y.ToString();
btnactiv.Text = "Dept " + dr_depts["code_dept"].ToString() + "(" + nbr + " )";
cell.Controls.Add(btnactiv);按钮被添加,工作正常,但是在我添加按钮之后,单元格的文本就被删除了,我如何添加butoons并保留文本呢?
发布于 2016-02-08 11:12:10
首先动态创建表格单元格,然后将文本和按钮添加到其中:
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);https://stackoverflow.com/questions/35267470
复制相似问题