【发布时间】:2019-10-01 06:16:03
【问题描述】:
我有下拉列表,其中列表项为是和否。我希望页面上显示“否”,但 ListItem 上的 Selected="true" 不起作用。
<asp:DropDownList ID="ddlIsDistributor" runat="server">
<asp:ListItem Value="1" Text="Yes">Yes</asp:ListItem>
<asp:ListItem Value="0" Text="No" Selected="True">No</asp:ListItem>
</asp:DropDownList>
【问题讨论】:
-
我相信你应该尝试使用
truesmall caps ...否则你也可以在后面添加一个代码,如ddlIsDistributor.SelectedValue = 1 -
查看declarative syntax 的
asp:DropDownList,Selected="True"应该适用于asp:ListItem。我什至无法重现您的问题。 -
我现在解决了这个问题。谢谢。