在我的页面上,我有一个DropDownList
,我用SqlDataSource
(请参阅下面的代码)填充数据库值。asp.net dropdownlist - 在db值之前添加空白行
如何在值之前添加自己的文本或空白行?
<asp:DropDownList ID="drpClient" runat="server" Width="200px"
AutoPostBack="True" DataSourceID="dsClients" DataTextField="name"
DataValueField="client_id">
</asp:DropDownList>
<asp:SqlDataSource ID="dsClients" runat="server"
ConnectionString="my_connection_string"
ProviderName="System.Data.SqlClient"
SelectCommand="SELECT [client_id], [name] FROM [clients]">
</asp:SqlDataSource>
谢谢。
P.S.你推荐使用SqlDataSource
还是以另一种方式填充?
这涉及到:http://stackoverflow.com/questions/267064/asp-net-add-blank-item-at-top-of-dropdownlist – mcfea 2014-04-16 23:19:03