解决方法
我想你想做的是这样的:
<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="true"> <asp:ListItem Text="--Select One--" Value="" /> </asp:DropDownList>
确保“AppendDataBoundItems”设置为true,否则当您绑定数据时,将清除“–Select One–”列表项。@H_301_3@
如果下拉列表的“AutoPostBack”属性设置为true,您还必须将“CausesValidation”属性设置为true,然后使用“requiredFieldValidator”确保“–Select One–”选项不会出现, t造成回发。@H_301_3@
<asp:requiredFieldValidator ID="requiredFieldValidator1" runat="server" ControlToValidate="DropDownList1"></asp:requiredFieldValidator>