如果复选框产生TRUE或FALSE,我如何转换为1或0以将值保存到数据库?
ASP.NET
<asp:CheckBox ID="cbTermsandcond" runat="server" />
C#
BTermsandcondParam = new SqlParameter();
BTermsandcondParam.ParameterName = "@BTermsandcondParam";
BTermsandcondParam.SqlDbType = SqlDbType.Bit;
BTermsandcondParam.Direction = ParameterDirection.Input;
BTermsandcondParam.Value = cbTermsandcond. ??? ;
编辑:
我写了这个有效。但是有更简单的方法吗?
if (cbTermsandcond.Checked == true)
{
BTermsandcondParam.Value = 1;
}
else
{
BTermsandcondParam.Value = 0;
}
此致 茶
答案 0 :(得分:0)
BTermsandcondParam.Value = cbTermsandcond.Checked