TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
suman goud
NA
176
54.6k
How insert selected drop down value in database
Aug 5 2016 8:33 AM
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<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
Reply
Answers (
2
)
How to use multiple entity models in single view in mvc 4
Diff Between Textbox.value and Textbox.Text