没有选定项目的 ASP.net DropDownList [英] ASP.net DropDownList with no selected item
本文介绍了没有选定项目的 ASP.net DropDownList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个添加了项目的 ASP DropDownList.我想要的只是在页面加载为空后进行选择,因此没有选择的项目.
I have a ASP DropDownList with items added to it. All what I want is to make the selection after the page loaded empty so there is no a 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文