Here i want to bind in drop-down from database using modal.But i bind the value using
viewdata. so kindly help how to bind drop-down from database using modals.
DESCRIPTION:-
in controller
PowerShell
ListSelectListItem> list = new ListSelectListItem>(); list.Add(new SelectListItem { Text = "Select Country", Value = "Select Country" });//set default text for DropdownList var cat = (from c in db.Country select c).ToArray();//get data from database using linq for (int i = 0; i cat.Length; i++) { list.Add(new SelectListItem { Text = cat[i].Country_Name, Value = cat[i].Country_Cde.ToString() }); } ViewData["ViewCountry"] = list;Kindly suggest Explain me how to bind values in drop-down from database using modals.

Guest UserRank #259 · 9.8K reputationPosted Jul 26, 2014, 9:14 PM EDT
http://www.codeproject.com/Articles/710776/Introduction-to-ASP-NET-MVC-Model-Binding-An-Absol
jothi kumar102 reputationPosted Jul 27, 2014, 8:49 PM EDT
Guest UserRank #259 · 9.8K reputationPosted Jul 27, 2014, 8:59 PM EDT
what's causing the NullReference exception? Is it list.Add or when you're assigning list back to Viewdata
jothi kumar102 reputationPosted Jul 27, 2014, 9:30 PM EDT
jothi kumar102 reputationPosted Jul 27, 2014, 9:31 PM EDT
Anupam SinghRank #643 · 3.7K reputationPosted Jul 27, 2014, 10:59 PM EDT
refer this thread : http://stackoverflow.com/questions/15402388/how-to-use-dropdownlistfor-in-mvc3-razor-with-model
jothi kumar102 reputationPosted Jul 27, 2014, 11:17 PM EDT