ASP.NET Web Forms DropDownList has a SelectedValue which is invalid because it does not exist in the list of items

前端 未结 6 919
孤独总比滥情好
孤独总比滥情好 2021-02-02 15:05

First of all there has been questions ( DropDownList has a SelectedValue which is invalid because it does not exist in the list of items , DropDownList "has a SelectedValue

6条回答
  •  感情败类
    2021-02-02 15:33

    I had a similar problem and fixed it by adding a DataBinding method.

    protected void myDDL_DataBinding(object sender, EventArgs e)
    {
        if (myDDL.SelectedIndex != -1)
        {
            myDDL.SelectedIndex = 0;
        }
    }
    

    On design page...

    
    
    

提交回复
热议问题