Dropdownlist我綁定的值,但在該dropdownlist就像組意味着(員工,非員工),所以項目值是空的(「」),所以我可以使用數據綁定事件拆分兩個fileds,這兩個領域我可以應用顏色和下劃線,並且用戶不會選擇該字段,所以請參閱下面的代碼並修改此代碼。使用asp.net使下拉列表中的某些項目不可選?
protected void ddlconsultant_DataBound(object sender, EventArgs e) { foreach (ListItem item in ((DropDownList)sender).Items) {
string r = item.Value; if (r == "") {
item.Attributes.Add("style", "color:Red;font-weight:bolder"); } }
感謝 hemanth
我在推薦你的答案,因爲它對用戶不允許使用javascript有好處。 – Mhmd
但它在回發中有問題 – Mhmd