Setting dropdownlist selecteditem programmatically

前端 未结 11 1731
北海茫月
北海茫月 2020-11-28 07:47

I want to set the selecteditem attribute for an ASP.Net dropdownlist control programmatically.

So I want to pass a value to the dropdownlist control to

11条回答
  •  再見小時候
    2020-11-28 08:14

    Here is the code I was looking for :

    DDL.SelectedIndex = DDL.Items.IndexOf(DDL.Items.FindByText("PassedValue"));
    

    Or

    DDL.SelectedIndex = DDL.Items.IndexOf(DDL.Items.FindByValue("PassedValue"));
    

提交回复
热议问题