2008-08-28 33 views

回答

4

在引擎蓋下,您可以訪問該項目的屬性併爲其分配一個CSS樣式。

所以,你應該能夠再編程通過指定分配給它:

RadioButtonList.Items(1).CssClass.Add("visibility", "hidden") 

,並把工作做好。

+0

` 'CssStyle'不是'System.Web.UI.WebControls.ListItem'的成員。'\t我知道nd設置可見性,但不知道CssStyle屬性來自哪裏...... – Airn5475 2012-08-28 20:43:48

+0

啊,一箇舊的錯字,它應該是CssClass屬性,而不是CssStyle。我已經更新了相應的東西。 – 2012-08-28 20:54:17

0

如果您的意思是使用JavaScript,並且如果我沒有記錯,您必須挖掘每個< input type =「radio」... >標記的ClientID屬性。

0

你試過隱藏它通過itemdatabound事件onload還是你需要它加載後隱藏?

0

我沒有測試過,但我認爲(對於C#)

foreach(ListItem myItem in rbl.Items) 
{ 
if(whatever condition) 
myItem.Attributes.Add("visibility","hidden"); 

} 
2

爲什麼不加,並根據需要進行刪除單選按鈕?

RadioButtonList.Items.Add("Item Name" or index); 
RadioButtonList.Items.Remove("Item Name" or index); 
0

試試這個:

RadioButtonList.Items.Remove(RadioButtonList.Items.FindByValue("3")); 
2

這裏是你怎麼也得一個樣式屬性應用到列表項:

RadioButtonList.Items(1).Attributes.Add("style", "display:none")
- 或 -
RadioButtonList.Items(1).Attributes.Add("style", "visibility:hidden")