DropDownList 禁止选择某一项

public void DisAbleDropDownListItem(DropDownList ddl)
        {
            foreach (ListItem li in ddl.Items)
            {
                if (li.Value == "1" || li.Text == "RUN")
                {
                    li.Attributes.Add("disabled""disabled");
                }
            }
        }

  protected void Page_Load(object sender, EventArgs e)
        {
            DisAbleDropDownListItem(ddl);
        }

在Page_Load时,应用这个方法。

原文地址:https://www.cnblogs.com/nanxiaoxiang/p/2727159.html