2012-07-27 59 views
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); 

回答

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); 
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); 
+0

同樣的作品,謝謝。 – Ted 2014-03-20 22:58:51