How to SELECT a dropdown list item by value programmatically

前端 未结 10 575
滥情空心
滥情空心 2020-12-13 00:11

How to SELECT a drop down list item by value programatically in C#.NET?

10条回答
  •  青春惊慌失措
    2020-12-13 00:40

    I prefer

    if(ddl.Items.FindByValue(string) != null)
    {
        ddl.Items.FindByValue(string).Selected = true;
    }
    

    Replace ddl with the dropdownlist ID and string with your string variable name or value.

提交回复
热议问题