【发布时间】:2015-08-26 06:46:18
【问题描述】:
我对@987654322@ 中的SelectedItem 有疑问
<asp:DropDownList ID="Etkin_Drop" runat="server" OnSelectedIndexChanged="Etkin_Drop_SelectedIndexChanged">
<asp:ListItem Text="Seç" Value="-1" Selected="True"></asp:ListItem>
<asp:ListItem Text="Aktif" Value="1"></asp:ListItem>
<asp:ListItem Text="Deaktif" Value="0"></asp:ListItem>
</asp:DropDownList>
第一个列表项值为-1,但是当我想检查 if 语句时它不起作用
protected void Etkin_Drop_SelectedIndexChanged(object sender, EventArgs e)
{
if (Convert.ToInt32(Etkin_Drop.SelectedItem.Value) == -1)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Lütfen Bir Seçim Yapınız');", true);
}
else
{
Label4.Text = Etkin_Drop.SelectedItem.Value;
}
}
我无法定义问题
【问题讨论】:
-
您如何确认它不起作用?你试过调试吗?
-
你能设置一个断点并检查你得到的值而不是 -1 吗?
-
是的,我确认了,脚本管理器应该发出警告,但它不会进入 if 语句
标签: c# asp.net drop-down-menu