2011-08-25 38 views
1

我一直在爲此工作了大約兩天....我有一個RadioButtonList,後來被用於打印PDF的RadioButtonListPrint取代。當單選按鈕不在表格中時它工作正常,但是在表格中我無法獲取ListPrint。任何ides?謝謝。如何在表格中顯示RadioButtonListPrint?

此代碼

Control ct; 
tempControl = new RadioButtonListPrint(); 
tempControl.ID = ct.ID + "_print"; 
((RadioButtonListPrint)tempControl).CopyRadioButtonListAttributes(((RadioButtonList)ct)); 
((RadioButtonList)ct).Visible = false;  
ct.Parent.Controls.Add(tempControl); 

有這個輸出...

enter image description here

回答

1

你必須找到你想要添加到,如果你只是把它添加到控制(表)容器它將只是最後一個ControlTree中的控件,如您所見:

標記:

<table> 
    <tr> 
    <td id="putMeHere" runat="server"></td> 
    </tr> 
</table> 

代碼:

HtmlTableCell td = [fill in the container control here].FindControl("putMeHere") as HtmlTableCell; // 
td.Controls.Add(tempControl); 
+0

感謝。我錯過了aspx頁面上的runat =「server」... oops :) – MrM