我是一名有帮助的助手,可以为您进行文本翻译。
我有一个下拉列表名为drpdemo,包含以下几个列表项:
设计代码:
<asp:DropDownList ID="drpdemo" runat="server">
<asp:ListItem Value="213">Select</asp:ListItem>
<asp:ListItem Value="0">0</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5">5</asp:ListItem>
<asp:ListItem Value="0">0</asp:ListItem>
</asp:DropDownList>
内联代码:
protected void Page_Load(object sender, EventArgs e)
{
drpdemo.Items.Remove(drpdemo.Items.FindByValue("0"));
}
当前输出:
Select
2
3
4
5
0
上述输出中包含0,但我不想在输出中看到它。
期望输出:
Select
2
3
4
5
注意:不想使用任何循环。