【发布时间】:2015-03-19 20:33:03
【问题描述】:
html 文件:
<p>Delivery Type :</p>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem Value="0">Electronic</asp:ListItem>
<asp:ListItem Value="1">Paper Mail</asp:ListItem>
</asp:RadioButtonList>
代码隐藏页面:
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
if(RadioButtonList1.SelectedItem.Value = )
{
}
}
我想使用单选按钮,以便如果用户选择电子邮件选项,则应显示电子邮件字段。因此,据我所知,我正在尝试如果 radiobuttonlist 选择的值为 0 则应显示电子邮件字段。但我在if 条件本身中遇到错误:
无法将类型字符串转换为布尔型
【问题讨论】:
-
无法将类型字符串转换为布尔型
-
RadioButtonList1.SelectedItem.Value是字符串,所以在 if 中您需要将其与字符串进行比较,例如RadioButtonList1.SelectedItem.Value == "0"
标签: c# asp.net radiobuttonlist