am binding values to drop down from database, but when am inserting selected value again in db am getting error 'object ref not set to instance of obj'
public class ReceiptsViewModel
{
public String Branch { get; set; }
public string Currency { get; set; }
public ActionResult Index()
{
ReceiptsViewModel objCustomermodel = new ReceiptsViewModel();
TestDemoEntities objentity = new TestDemoEntities();
List<MasterNode> objCus = (objentity.MasterNodes.Where(x => x.Type == "Master")).ToList();
MasterNode objCustomer = new MasterNode();
objCustomer.Name = "Select";
objCustomer.EmpID = 0;
objCus.Insert(0, objCustomer);
SelectList CustomerList = new SelectList(objCus, "EmpID", "Name");
objCustomermodel.CustomerListModel = CustomerList;
return View(objCustomermodel);
}
view
@Html.DropDownListFor(u => u.Account, Model.AccountListModel, new { @style = "width:150px;height:22px;", @id = "ddlAccount" })
am getting error here
'
Object reference not set to an instance of an object.
'
how to insert selected value in database