2013年6月10日 星期一

ASP.Net 隱藏 RadioButtonList 裡的項目

ASP.Net 的 RadioButtonList 是一個蠻好用的控制項,用了他就不用拉好幾個 RadioButton 了。不過有一個困擾的地方就是他的 Item 並沒有 Visible 的屬性,使得有時想要隱藏某些項目時感覺有些困擾

其實,沒有 Visible 屬性也沒有關係,他有 Arrtibutes 屬性可以用,只要用
RadioButtonList1.Items[0].Attributes.Add("style", "display:none");
或是
RadioButtonList1.Items[0].Attributes["style"] = "display:none";
就可以隱藏第 0 個 item 了

提供給大家參考

沒有留言: