我想将一个链接按钮控件添加到表格单元格,服务器端。单元格中还有文本,当我添加它时会被控件覆盖。如何将控件添加到单元格并保留文本?
//Create a table cell and add text to it
TableCell commentCell = new TableCell();
commentCell.Text = "Text to remain in the cell."
//Create a linkbtn and add it to the table cell
LinkButton lbtnComments = new LinkButton();
lbtnComments.Text = "...";
lbtnComments.Style["float"] = "right";
commentCell.Controls.Add(lbtnComments);
答案 0 :(得分:2)
我只需在LinkButton
之前添加Label
:
TableCell commentCell = new TableCell();
Label lblComment = new Label();
lblComment.Text = "Text to remain in the cell."
commentCell.Controls.Add(lblComment);
LinkButton lbtnComments = new LinkButton();
commentCell.Controls.Add(lbtnComments);
答案 1 :(得分:0)
将文字添加到LiteralControl:
//Create a table cell and add text to it
TableCell commentCell = new TableCell();
commentCell.Controls.Add(new LiteralControl("Text to remain in the cell.");
//Create a linkbtn and add it to the table cell
LinkButton lbtnComments = new LinkButton();
lbtnComments.Text = "...";
lbtnComments.Style["float"] = "right";
commentCell.Controls.Add(lbtnComments);