我可以在下拉列表中有一个值为0的空白字符串吗?

Dan*_*ard 2 asp.net drop-down-menu

我的asp.net下拉列表中需要一个listitem,其值为0,文本为空字符串.我在我的代码中将db查询的结果附加到它.如果我有以下标记,它会为值和文本呈现为0:

<asp:DropDownList id="dd1" runat="server" AppendDataBoundItems="true">
   <asp:ListItem Value="0"></asp:ListItem>
</asp:DropDownList>
Run Code Online (Sandbox Code Playgroud)

有没有办法在我的代码中不创建插入listitem对象的情况下拥有它我想要的方式?

谢谢!

Gra*_*ark 5

设置Text属性,例如

<asp:DropDownList id="dd1" runat="server" AppendDataBoundItems="true">
   <asp:ListItem Value="0" Text="" />
</asp:DropDownList>
Run Code Online (Sandbox Code Playgroud)