How to add an item to a drop down list in ASP.NET?

后端 未结 3 1355
孤城傲影
孤城傲影 2021-02-01 02:18

I want to add the "Add new" at a specific index, but I am not sure of the syntax. I have the following code:

protected void Page_Load(object sender, Eve         


        
3条回答
  •  天涯浪人
    2021-02-01 03:22

    Try this, it will insert the list item at index 0;

    DropDownList1.Items.Insert(0, new ListItem("Add New", ""));
    

提交回复
热议问题