DropdownList用法记录

1.AppendDataBoundItems="true" 第一个为用户选择的提示信息 ---请选择---,而在与sqldatasource或其他数据源绑定后,其不会消失 ,这个属性能够将动态绑定数据和静态数据,合并显示出来。

<asp:DropDownList ID="DropDownList1" AppendDataBoundItems="true" runat="server" DataSourceID="SqlDataSource1" DataTextField="state" DataValueField="state">

    <asp:ListItem Text="---请选择---" Value="" />   

</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"

                   ConnectionString="<%$ ConnectionStrings:pubsConnectionString %>"

                   SelectCommand="SELECT DISTINCT [state] FROM [authors]">

</asp:SqlDataSource>
原文地址:https://www.cnblogs.com/chenqingwei/p/1733667.html