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>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-17
  • 2021-10-30
  • 2021-05-23
猜你喜欢
  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
相关资源
相似解决方案