RadioButtonList验证索引

时间:2015-10-05 11:21:55

标签: c# asp.net

我有一个Radiobuttonlist,我想在选择值为1的Item后做某事。当我使用 RadioButtonListType.SelectedValue 返回“”时,当我使用 RadioButtonListType.SelectedIndex 时返回 -1 。 我在哪里做错了?

这是我的代码

aspx

 <asp:RadioButtonList ID="RadioButtonListType" runat="server" OnSelectedIndexChanged="RadioButtonListType_SelectedIndexChanged" ValidationGroup="emergency" AutoPostBack="True">
                                <asp:ListItem Value="0">Normal</asp:ListItem>
                                <asp:ListItem Value="1">Emergency</asp:ListItem>
                            </asp:RadioButtonList>

的.cs

protected void RadioButtonListType_SelectedIndexChanged(object sender, EventArgs e)
{
    if (RadioButtonListSF.SelectedIndex == 1)
    {
        MPEEmergency.Show();
    }
}

0 个答案:

没有答案