Stacie
asked on
MVC4 , error never seen before
Can you please post the GET method in your controller for this view?
ASKER
Here is my code for my get method.
The problem is try to populate a drop down list. I get the error as soon as I try to populate the viewBag.libraryId
ViewBag.libraryId = ReturnLibraryFolderSelectL ist(librar yFolderRep ository.Re turnList(C lientId), package.libraryFolderId);
Here is my Base Controler that the ReturnLibraryFolderSelectL ist is from:
public SelectList ReturnLibraryFolderSelectL ist(IList< LibraryFol der> libraryfolder, int libraryFolderId)
{
LibraryFolder gbl = new LibraryFolder() { description = "Select a Folder", id = NEW_INT, inactive = false };
libraryfolder.Insert(0, gbl);
return new SelectList(libraryfolder, "id", "description", libraryFolderId);
}
public class LibraryFolder : BaseModel, ILibraryFolderRepository
{
public int id { get; set; }
//the value of the description for the dropDown
[Display(Name = "description")]
[Required(ErrorMessage = "description is required")]
public string description { get; set; }
[Display(Name = "Client")]
[ForeignKey("client")]
public int clientId { get; set; }
public virtual Client client { get; set; }
/// <summary>
/// whether the language is inactive
/// </summary>
[Display(Name = "Inactive")]
[Required(ErrorMessage = "Inactive is required")]
public bool inactive { get; set; }
public IList<LibraryFolder> ReturnList(int clientId)
{
return db.LibraryFolders.Where(l => l.clientId == clientId && l.inactive == false).ToList();
}
The problem is try to populate a drop down list. I get the error as soon as I try to populate the viewBag.libraryId
ViewBag.libraryId = ReturnLibraryFolderSelectL
Here is my Base Controler that the ReturnLibraryFolderSelectL
public SelectList ReturnLibraryFolderSelectL
{
LibraryFolder gbl = new LibraryFolder() { description = "Select a Folder", id = NEW_INT, inactive = false };
libraryfolder.Insert(0, gbl);
return new SelectList(libraryfolder, "id", "description", libraryFolderId);
}
public class LibraryFolder : BaseModel, ILibraryFolderRepository
{
public int id { get; set; }
//the value of the description for the dropDown
[Display(Name = "description")]
[Required(ErrorMessage = "description is required")]
public string description { get; set; }
[Display(Name = "Client")]
[ForeignKey("client")]
public int clientId { get; set; }
public virtual Client client { get; set; }
/// <summary>
/// whether the language is inactive
/// </summary>
[Display(Name = "Inactive")]
[Required(ErrorMessage = "Inactive is required")]
public bool inactive { get; set; }
public IList<LibraryFolder> ReturnList(int clientId)
{
return db.LibraryFolders.Where(l => l.clientId == clientId && l.inactive == false).ToList();
}
At what point in the ReturnLibraryFolderSelectL ist method does the error occur? You should be able to drop a breakpoint in the method and step through the code. Are the input / output values what you expect?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Because I was able to figure the problem.
ASKER