in Page_Load after possible initialization, try to doif (!IsPostBack) List1.SelectedIndex = -1;
sorry, I was wrong, do something like (change "DropDown1" to the name of your 下拉列表框):if (!IsPostBack) { String scriptString = "<script language=JavaScript>function window.onload(){document.all('DropDown1').selectedIndex=-1;}<"; scriptString += "/"; scriptString +="script>"; this.RegisterClientScriptBlock("clientScript", scriptString); }
来自在线帮助的信息让我好生失望... 哎,各位说的好象都不行耶...我看了.net的在线帮助,发现这么一句“ An item is always selected in the DropDownList control. You cannot deselect every item in the list at the same time.”似乎我的愿望是不可实现的了... 不过还是要谢谢大家的帮助! ——————————————————[C#] public override int SelectedIndex {get; set;}Property Value The index of the selected item in the DropDownList control. The default value is 0, which selects the first item in the list.Res Use the SelectedIndex property to programmatically specify or determine the index of the selected item from the DropDownList control. An item is always selected in the DropDownList control. You cannot deselect every item in the list at the same time.Note The indexes for the items in the DropDownList control are zero-based.
List1.SelectedIndex = -1;
{
String scriptString = "<script language=JavaScript>function window.onload(){document.all('DropDown1').selectedIndex=-1;}<";
scriptString += "/";
scriptString +="script>";
this.RegisterClientScriptBlock("clientScript", scriptString);
}
哎,各位说的好象都不行耶...我看了.net的在线帮助,发现这么一句“ An item is always selected in the DropDownList control. You cannot deselect every item in the list at the same time.”似乎我的愿望是不可实现的了...
不过还是要谢谢大家的帮助!
——————————————————[C#]
public override int SelectedIndex {get; set;}Property Value
The index of the selected item in the DropDownList control. The default value is 0, which selects the first item in the list.Res
Use the SelectedIndex property to programmatically specify or determine the index of the selected item from the DropDownList control. An item is always selected in the DropDownList control. You cannot deselect every item in the list at the same time.Note The indexes for the items in the DropDownList control are zero-based.