[英]How to change the label at the time of radio button selection is changed using asp.net?
这是我在asp.net中的以下内容
<asp:RadioButtonList ID="RbList" runat="server"
onselectedindexchanged="RbList_SelectedIndexChanged">
<asp:ListItem Text="Male" Value="1"></asp:ListItem>
<asp:ListItem Text="Female" Value="2"></asp:ListItem>
</asp:RadioButtonList>
<asp:Label ID="lbltest" runat="server"></asp:Label>
这是我的RBList_SelectedIndexChanged
事件。
int i = RbList.SelectedIndex;
if (i == 1)
{
lbltest.Text = "You have click on male";
}
if (i == 2)
{lbltest.Text = "You have click on female";}
现在,我希望在选择项目1时,文本标签必须根据所选项目的radiobutton列表。
怎么可能这样呢?
问候。
将您的代码更改为以下内容:
int i = RbList.SelectedIndex; if (i == 0) { lbltest.Text = "You have click on male"; } else if (i == 1) { lbltest.Text = "You have click on female"; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.