Click here to Skip to main content
15,068,988 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My View page code:
@Html.CheckBox("0",new {chkbxusertype = Model.User_Type})

My Controller page code:
           if (ModelState.IsValid)
              var dbedit = db.WorkTracker_Login.SingleOrDefault(p => p.User_Id == id);
               dbedit.Username = worktracker_login.Username;
               dbedit.Password = worktracker_login.Password;
               //var UserType=worktracker_login.User_Type;
                 //bool checkvalue = bool.Parse(Request.Form.GetValues("chkbxusertype")[0]);
               bool checkvalue = bool.Parse(Request.Form.GetValues("chkbxusertype")[1]);// Error occurs in this line
                 if (checkvalue == true)
                     dbedit.User_Type = 1;
                     dbedit.User_Type = 2;
               return RedirectToAction("Index");
           return View(worktracker_login);

Please help in the statement with bool checkvalue. Error exists : Object reference not set

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