2012-05-02 35 views
1

我需要在列表項目之間添加一些文本,但我還沒有看到這樣做的方法。我已經看過在項目之間添加空格,但我無法弄清楚如何在列表項目之間添加文本。在單選按鈕控件列表中的項目之間添加文本

<asp:RadioButtonList ID="RadioButtonList1" runat="server" > 
need to add text here 
    <asp:ListItem Value="10.00" Selected="True">this is item1</asp:ListItem> 
need to add text here 
    <asp:ListItem Value="10.00">this is item2 </asp:ListItem> 
need to add text here 
    <asp:ListItem Value="10.00"> this is item3 </asp:ListItem> 

</asp:RadioButtonList> 

回答

1

您可以使用多個RadioButton控件來實現,也可以根據需要對它們進行分組。

RadioButtonList不會讓你在兩者之間插入文本。下面是從MSDN報價:

RadioButtonList控件不允許你按鍵之間 插入文本,但要容易得多,如果你想 綁定按鈕到數據源來使用。編寫檢查 哪個按鈕已被選中的代碼也稍微容易一些。

0

我想創建一個自定義RadioButtonList控件,讓您可以在您的客戶列表項的屬性適當地實現自己的自定義列表項的類型和render值。

列表項是密封的,所以你不能從它繼承。不過,您可以讓自己的類模仿ListItem,併爲您希望能夠顯示每個列表項目的添加文本添加更多屬性。

然後,在自定義單選按鈕列表的Render方法,你可以呈現一個標籤,並輸出正常的列表項屬性之前,你在那些之間的文本 - 文本和值。

HTH

相關問題