c#中如何获取Radiobutton的值
我把两个Radiobutton放在一个组里..一个是男.一个是女..我想点击一个提交按钮后保存到数据库中.....数据库中字段类型为bit,怎么把Radiobutton的...
我把两个Radiobutton放在一个组里..一个是男.一个是女..我想点击一个提交按钮后保存到数据库中.....数据库中字段类型为bit, 怎么把Radiobutton的值转换保存???
展开
2个回答
展开全部
应该是用“RadioButtonList ”,
.ASPX
<asp:RadioButtonList ID="RadioButtonList1" runat="server" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
RepeatDirection="Horizontal" RepeatLayout="Flow">
<asp:ListItem Value="True">男</asp:ListItem>
<asp:ListItem Value="False">女</asp:ListItem>
</asp:RadioButtonList>
.CS
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
bool sex = Convert.ToBoolean(RadioButtonList1.SelectedValue);
}
.ASPX
<asp:RadioButtonList ID="RadioButtonList1" runat="server" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
RepeatDirection="Horizontal" RepeatLayout="Flow">
<asp:ListItem Value="True">男</asp:ListItem>
<asp:ListItem Value="False">女</asp:ListItem>
</asp:RadioButtonList>
.CS
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
bool sex = Convert.ToBoolean(RadioButtonList1.SelectedValue);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询