I'am trying to insert some data from ASP.NET DropDownList and CheckBox to database if the Checkbox is checked I want to insert DropDownList value if not checked I want to pass null. But in my table it inserts 0 not NULL How can I pass null instead of zero (0) if it is not checked? Her is my code:
if (CheckBoxMorning.Checked == true)
{
SqlParameter paramMorning = new SqlParameter("@Morning", DropDownMorning.SelectedValue);
cmd.Parameters.Add(paramMorning);
}
else
{
SqlParameter paramMorning = new SqlParameter("@Morning", CheckBoxMorning.Checked);
cmd.Parameters.Add(paramMorning);
}
Thank you in advance
Aucun commentaire:
Enregistrer un commentaire