0

我想在服务器端的表格单元格中添加一个链接按钮控件。该单元格中还有文本,当我添加它时,它会被控件覆盖。如何将控件添加到单元格并保留文本?

        //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);
4

2 回答 2

2

Label我会在你之前添加一个LinkButton

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);
于 2012-07-27T18:27:00.227 回答
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);
于 2014-03-20T14:30:22.097 回答