どうすればこのエラーをキャッチできますか?
DropdownList1.SelectedValue = strText;
これはエラーです:
DropdownList1 の選択された値は、アイテムのリストに表示されないため無効です。
strText が dropdownlist1 に存在するようなものでキャッチできますか?
どうすればこのエラーをキャッチできますか?
DropdownList1.SelectedValue = strText;
これはエラーです:
DropdownList1 の選択された値は、アイテムのリストに表示されないため無効です。
strText が dropdownlist1 に存在するようなものでキャッチできますか?
DropDownList.Items.FindByValueを使用できます
if( ItemCollection.FindByValue(strText) != null)
{
DropdownList1.SelectedValue = strText;
}
このように使用できます
DropdownList1.SelectedIndex =
DropdownList1.Items.IndexOf(DropdownList1.Items.FindByValue(strText));
ドロップダウンリストのselecteditem
をプログラムで設定する