protected void Button1_Click1(object sender, EventArgs e)
{
try
{
string str = mas.empdetadd(CheckBox1.Checked.ToString(), CheckBox2.Checked.ToString(), CheckBox3.Checked.ToString(), CheckBox4.Checked.ToString(), txtnom.Text, ddgroup.SelectedItem.Text);
if (str == "1")
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", "alert('Employee Details Already Added In this ID ..!!');", true);
}
else
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", "alert('Employee Details Added Succesfully..!!');", true);
}
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
}
我有4个复选框。目前,当我点击一个复选框时,它将返回值为“true”和“false”。我想将这个真值保存为“1”,将假值保存为“0”到数据库中。我怎样才能做到这一点。此外,如何清除该复选框按钮单击事件后设置复选框值
我的班级
public string empdetadd(string ot, string pf, string esi, string tds)
{
string qry = "insert into EmpDetails values(+ ot + "','" + pf + "','" + esi + "','" + tds + "')";
}
'INT I = checkbox.Checked? 1:0;'用'I'做什么你想要什么 – Reniuz 2014-09-26 06:12:33
请改善你的问题。它不显示代码将值保存到数据库的位置。只需使用if(CheckBox1.Checked)而不是将其转换为字符串。 'Set Checkbox1.Checked = false'用于清除复选框 – CarbineCoder 2014-09-26 06:16:46
Ot,pf,esi和tds是checkbox1,checkbox2,checkbox3和checkbox4.I不知道如何将其值转换为1和0. – 2014-09-26 06:21:21