How to add a default “Select” option to this ASP.NET DropDownList control?

后端 未结 7 2087
别那么骄傲
别那么骄傲 2021-01-02 05:06

I am a new ASP.NET developer and I am trying to learn Linq-To-Entities. I am trying to bind a DropDownList with the Linq statement for retrieving the list of status in the S

相关标签:
7条回答
  • 2021-01-02 05:40

    If you want to make the first item unselectable, try this:

    DropDownList1.Items.Insert(0, new ListItem("Select", "-1"));
    DropDownList1.Items[0].Attributes.Add("disabled", "disabled");
    
    0 讨论(0)
提交回复
热议问题