本文介绍了没有选定项目的ASP.net DropDownList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个ASP DropDownList,其中添加了项目。所有我想要的是在页面加载后进行选择,所以不应该选择项目。
I have a ASP DropDownList with item added to it. all what I want is to make the selection after the page loaded empty so there should not be selected item.
我该怎么做
推荐答案
您可以通过以下方式以编程方式添加一个空项目到您的下拉列表的顶部:
You can add an empty item to the top of your dropdownlist programmatically like this:
myDropDown.Items.Insert(0, new ListItem(string.Empty, string.Empty));
myDropDown.SelectedIndex = 0;
这篇关于没有选定项目的ASP.net DropDownList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!