【发布时间】:2015-08-24 08:32:10
【问题描述】:
我是 asp.net 和 c# 的新手。尝试检查单选按钮是否被选中。如果它选择了 else 子句将起作用如果它没有被选择想要设置 lbl_hata 为“EMPTY!!”文本。
我也尝试过 selectedIndexChanged,但没有成功。 我该如何解决这种情况?
if (RadioButtonList_gorusmeYapilanOkul.SelectedValue == "")
{
lbl_hata.Text = "EMPTY!!";
}
if (yetkiliAdSoyad_txt.Text=="")
{
lbl_hata.Text = "EMPTY!!";
}
这是aspx页面;
<td class="auto-style2">
<asp:RadioButtonList ID="RadioButtonList_gorusmeYapilanOkul" runat="server" Width="174px" >
<asp:ListItem Value="Seyrantepe Şube 1">Seyrantepe Şube 1</asp:ListItem>
<asp:ListItem Value="Seyrantepe Şube 2">Seyrantepe Şube 2</asp:ListItem>
</asp:RadioButtonList>
</td>
【问题讨论】:
-
您在
lbl_hata.Text = "EMPTY!之后缺少",这可能不是因为您编辑了帖子而导致的错误? -
我错过了“写在这里。但它在我的代码中。并且不起作用。
-
请解释:不工作。
-
我的 else 子句在 mysql 中插入数据。当我在运行项目后查看我的数据库时,如果子句不检查单选按钮被选中或未选中,那么 else 子句工作并在数据库中插入数据。
-
"else clause will work" 你没有
else。调试时RadioButtonList_gorusmeYapilanOkul.SelectedValue的值是多少?
标签: c# asp.net radiobuttonlist selectedvalue selectedindexchanged