2016-02-08 35 views
0

我有其中所有的單元包含文本和下面的函數來按鈕添加到細胞加入Dynamicaly添加按鈕到ASP表格單元不刪除細胞文本

Button btnactiv = new Button(); 
        btnactiv.ID = y.ToString(); 
        btnactiv.Text = "Dept " + dr_depts["code_dept"].ToString() + "(" + nbr + ")"; 
        cell.Controls.Add(btnactiv); 

按鈕和它的asp.table工作正常,但我添加按鈕後,單元格的文本被刪除如何添加butoons並保留文本?

+0

可以顯示在按鍵相同的文字? – Mairaj

+0

nope文本是日期和一個單元格可以包含很多按鈕,我需要在按鈕上方的每個單元格中顯示日期 –

回答

2

第一動態創建一個表格單元格,然後你的文字和按鈕添加到它:

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

OMG thnx聰明的方法來做到這一點 –

相關問題