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'
my model
public class ReceiptsViewModel
{
public String Branch { get; set; }
public string Currency { get; set; }
public SelectList CustomerListModel { get; set; }
public SelectList AccountListModel { get; set; }
}
controller
public ActionResult Index()
{
ReceiptsViewModel objCustomermodel = new ReceiptsViewModel();
TestDemoEntities objentity = new TestDemoEntities();
List 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
Rajendra MotePosted Aug 10, 2016, 10:20 AM
Bikesh SrivastavaPosted Aug 5, 2016, 8:52 AM