Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have the following code for my check boxes;

View

@Html.LabelFor(model => model.Shipper_SMS_Alert_Bid)


@Html.CheckBox("Shipper_SMS_Alert_Bid", "Shipper_SMS_Alert_Bid")
@Html.ValidationMessageFor(model => model.Shipper_SMS_Alert_Bid)




@Html.LabelFor(model => model.Shipper_Email_Alert_Bid)


@Html.CheckBox("Shipper_Email_Alert_Bid", "Shipper_Email_Alert_Bid")

@Html.ValidationMessageFor(model => model.Shipper_Email_Alert_Bid)


Controller
C#
if (Convert.ToBoolean(Shipper_SMS_Alert_Bid) == true)
           {
               objShipper.Shipper_SMS_Alert_Bid = 'Y';
           }
           else
           {
               objShipper.Shipper_SMS_Alert_Bid = 'N';
           }

           if (Convert.ToBoolean(Shipper_Email_Alert_Bid)== true)
           {
               objShipper.Shipper_Email_Alert_Bid = 'Y';
           }
           else
           {
               objShipper.Shipper_Email_Alert_Bid = 'N';
           }


               dcfx.FxShippers.InsertOnSubmit(shipper);
               dcfx.SubmitChanges();
               return RedirectToAction("Index");



       }


I would like to POST 'Y' or 'N' if the check box is checked or unchecked respectively but the above inserts a NULL value in the database. How do I correct this? I am using MVC with LINQ.

Thnx in advance.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900