我们在使用dropdownlist时,经常会选择从数据库提取信息绑定上,但是我们想在这些选项上面加一项 “请选择”
在前台dropdownlist标签里加一句<asp:ListItem
Selected=True>请选择</asp:ListItem>
同时:AppendDataBoundItems="True"
示例:
<asp:DropDownList ID="DropDownList4" runat="server" Width="80px"
AppendDataBoundItems="True"
DataSourceID="SqlDataSource1" DataTextField="height" DataValueField="height">
<asp:ListItem Selected=True>请选择</asp:ListItem>
</asp:DropDownList>
DataSourceID="SqlDataSource1" DataTextField="height" DataValueField="height">
<asp:ListItem Selected=True>请选择</asp:ListItem>
</asp:DropDownList>
转载于:https://blog.51cto.com/sunzhilu/925159