前台:
<asp:RadioButtonList ID="RadioButtonList1" runat="server"
RepeatDirection="Horizontal">
<asp:ListItem Value="0">男</asp:ListItem>
<asp:ListItem Value="1">女</asp:ListItem>
<asp:ListItem Value="2">保密</asp:ListItem>
</asp:RadioButtonList>
后台:
if (RadioButtonList1.SelectedValue == "0")
{
sqlcmm.Parameters.Add("@sex", System.Data.SqlDbType.NVarChar, 50).Value = "男";
}
else if (RadioButtonList1.SelectedValue == "1")
{
sqlcmm.Parameters.Add("@sex", System.Data.SqlDbType.NVarChar, 50).Value = "女";
}
else
{
sqlcmm.Parameters.Add("@sex", System.Data.SqlDbType.NVarChar, 50).Value = "保密";
}
本文介绍了一个ASP.NET应用程序中的性别选择组件实现方法,通过RadioButtonList控件进行水平排列,并展示了如何将用户的选择(男、女、保密)转换为数据库参数。

被折叠的 条评论
为什么被折叠?



